Windows System Environment Variables in "Sql * plus"
Can i use/reference Windows System Environment variables in "Sql * plus"?
For example, i want to create sql-script to run in database server computer that asks variable "ORA_HOME" and uses this value to execute some sql/plsql sentences.
Oracle 10g Personal, Windows 7.
Edited by: CharlesRoos on 12.11.2010 17:28
CharlesRoos wrote:
Business problem:
I have created 2 databases in my computer. Both databases needs tablespaces created by a script. Tablespaces' datafiles (.dbf files) names are same for both database. Both database has it's own directory where it holds datafiles at the moment. At the moment the datafiles for Database1 are in folder something like "%ORACLE_HOME%"\oradata\%databasename1%\*.dbf, and second database has its datafiles in other folder, somewhere ""%ORACLE_HOME%"\oradata\%databasename1%\*.dbf". I want now the script to create tablespace called "INDX" with same datafile name "indx1.dbf" into both database. So into both mentioned folder the file "indx1.dbf" must be created by script. I think the script should do following:
1. get ORACLE_HOME.
2. connect to database "databasename1"
3. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename1 || indx1.dbf"
4. connect to database "databasename2"
5. EXECUTE IMMEDIATE "Create TableSpace INDX....file=%ORACLE_HOME% || databasename2 || indx1.dbf"I don't have Oracle database near by anymore, so the code was pseudocode.
I don't understand how to use ?-shortcut.OK, my first impression is "why does this even NEED to be scripted? Creation of new tablespaces is usually a one-off operation.
But that aside how about this sqlplus command-line substitution variables. This example is in linux, but will work as well in Windows with the change of the way environment variables are referenced:
*nix - echo $myvariable
Windows - echo %myvariable%
First, the sqlscript to create the TS. Note the use of the substitution variable "&1"
{code}
[oracle@vmlnx01 ~]$ cat cat makets.sql
set echo on feedback on verify on trimsp on
prompt &1
CREATE SMALLFILE TABLESPACE EDSTEST
DATAFILE '/ora01/oradata/&1/edstest.dbf'
SIZE 5M
REUSE
AUTOEXTEND ON
NEXT 1280K
MAXSIZE 32767M
LOGGING
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
drop tablespace edstest
including contents and datafiles
exit
{code}
So, at the OS prompt: Notice that the @ is separated by a space, makeing it a command line parm instead of part of the connect string
{code}
[oracle@vmlnx01 ~]$ export myparm=vlnxora1
[oracle@vmlnx01 ~]$ sqlplus system/pswd @makets $myparm
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Nov 12 13:18:05 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> prompt &1
vlnxora1
SQL> --
SQL> CREATE SMALLFILE TABLESPACE EDSTEST
2 DATAFILE '/ora01/oradata/&1/edstest.dbf'
3 SIZE 5M
4 REUSE
5 AUTOEXTEND ON
6 NEXT 1280K
7 MAXSIZE 32767M
8 LOGGING
9 EXTENT MANAGEMENT LOCAL
10 SEGMENT SPACE MANAGEMENT AUTO
11 ;
old 2: DATAFILE '/ora01/oradata/&1/edstest.dbf'
new 2: DATAFILE '/ora01/oradata/vlnxora1/edstest.dbf'
Tablespace created.
SQL> --
SQL> drop tablespace edstest
2 including contents and datafiles
3 ;
Tablespace dropped.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@vmlnx01 ~]$
{code}
Similar Messages
-
Which Oracle folders into "PATH" system Environment Variable
Which Oracle folders must exist into "PATH" system Environment Variable in Windows OS?
The folders must contain Oracle command line utilities, like "sql * plus", "exp" and so on.The path to your bin folder ...
for eg :
D:\oracle\product\10.2.0\db_1\bin;Cheers :)
Renjith Madhavan -
Referencing a system environment variable
Hi all,
I am attempting to reference a system environment variable in an OS command within a package. However, it continues to error out with the generic "Wrong process return code" error. For now, I am assuming this is due to my reference to a system variable in the file path.
Note: when I'm directly on the ODI server and type in the exact same command into a command window, it works fine. It doesn't work when I call it from the generated scenario, via the Operator client on my computer.
Here is an example of my call line:
essmsh.exe %SysVarName%\somefile.mxl
Does anyone know how to reference the system environment variable correctly? Or...is there a better way to accomplish the same task?
Thanks!
-OSThank you for your response, Ankit!
Yes, essmsh.exe must be visible to the agent, because if I replace the reference to the system variables with hard-coded values, the scenario executes with no error.
I am not familiar with Jython procedures, and I am hesitant to create any as the there is no one on the team who can support them. Is there no direct reference one can use directly from the package/scenario? It seems odd that there is no current way to handle this, but perhaps I am naive. -
Unable to access value in System Environment Variable using Java
I am using Java code to get the value of a System Environment Variable using the Runtime, Process java classes.
The code works fine in tomcat, but when deployed in 9ias the code is unable to retrieve the value stored in the System environment variable in Windows 2000.Thanks for the comment steve, here is the code which i am using.
public String getEnvironmentVariable()
// This will get the FEDREP_HOME environment variable
String FEDREP_HOME = null;
Process p = null;
Runtime rt = Runtime.getRuntime();
try {
// invokes a shell-command to retrieve FEDREP_HOME variable
String OS = System.getProperty("os.name").toLowerCase();
// Get the Windows 95 environment variable
if (OS.indexOf("windows 9") > -1)
p = rt.exec( "command.com /c echo %FEDREP_HOME%" );
// Get the Windows NT environment variable
else if (OS.indexOf("nt") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the Windows 2000 environment variable
else if (OS.indexOf("2000") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the Windows XP environment variable
else if (OS.indexOf("xp") > -1)
p = rt.exec( "cmd.exe /c echo %FEDREP_HOME%" );
// Get the unix environment variable
else if (OS.indexOf("linux") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
// Get the unix environment variable
else if (OS.indexOf("unix") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
// Get the unix environment variable
else if (OS.indexOf("sunos") > -1)
p = rt.exec( "sh -c echo $FEDREP_HOME" );
} else
System.out.println("OS not known: " + OS);
// set up to read subprogram output
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// read output from subprogram
FEDREP_HOME = br.readLine();
br.close();
} catch(Exception ex)
System.out.println("Error when getting FEDREP_HOME environment variable");
ex.printStackTrace();
return(FEDREP_HOME); -
How to get system Environment variable?
How to get system Environment variable without using jni?
just like "JAVA_HOME" or "PATH"...
Any reply is help to me!! :-)Thx for your reply...
I get it!!!
Read environment variables from an application
Start the JVM with the "-D" switch to pass properties to the application and read them with the System.getProperty() method. SET myvar=Hello world
SET myothervar=nothing
java -Dmyvar="%myvar%" -Dmyothervar="%myothervar%" myClass
then in myClass String myvar = System.getProperty("myvar");
String myothervar = System.getProperty("myothervar");
This is useful when using a JAVA program as a CGI.
(DOS bat file acting as a CGI) java -DREQUEST_METHOD="%REQUEST_METHOD%"
-DQUERY_STRING="%QUERY_STRING%"
javaCGI
If you don't know in advance, the name of the variable to be passed to the JVM, then there is no 100% Java way to retrieve them.
NOTE: JDK1.5 provides a way to achieve this, see this HowTo.
One approach (not the easiest one), is to use a JNI call to fetch the variables, see this HowTo.
A more low-tech way, is to launch the appropriate call to the operating system and capture the output. The following snippet puts all environment variables in a Properties class and display the value the TEMP variable. import java.io.*;
import java.util.*;
public class ReadEnv {
public static Properties getEnvVars() throws Throwable {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
// System.out.println(OS);
if (OS.indexOf("windows 9") > -1) {
p = r.exec( "command.com /c set" );
else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 2000") > -1 )
|| (OS.indexOf("windows xp") > -1) ) {
// thanks to JuanFran for the xp fix!
p = r.exec( "cmd.exe /c set" );
else {
// our last hope, we assume Unix (thanks to H. Ware for the fix)
p = r.exec( "env" );
BufferedReader br = new BufferedReader
( new InputStreamReader( p.getInputStream() ) );
String line;
while( (line = br.readLine()) != null ) {
int idx = line.indexOf( '=' );
String key = line.substring( 0, idx );
String value = line.substring( idx+1 );
envVars.setProperty( key, value );
// System.out.println( key + " = " + value );
return envVars;
public static void main(String args[]) {
try {
Properties p = ReadEnv.getEnvVars();
System.out.println("the current value of TEMP is : " +
p.getProperty("TEMP"));
catch (Throwable e) {
e.printStackTrace();
Thanks to W.Rijnders for the W2K fix.
An update from Van Ly :
I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit: else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 2000") > -1 )
|| (OS.indexOf("windows 2003") > -1 ) // works but is quite specific to 2003
|| (OS.indexOf("windows xp") > -1) ) {
else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 20") > -1 ) // probably is better since no other OS would return "windows" anyway
|| (OS.indexOf("windows xp") > -1) ) {
I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9."
On Windows, pre-JDK 1.2 JVM has trouble reading the Output stream directly from the SET command, it never returns. Here 2 ways to bypass this behaviour.
First, instead of calling directly the SET command, we use a BAT file, after the SET command we print a known string. Then, in Java, when we read this known string, we exit from loop. [env.bat]
@set
@echo **end
[java]
if (OS.indexOf("windows") > -1) {
p = r.exec( "env.bat" );
while( (line = br.readLine()) != null ) {
if (line.indexOf("**end")>-1) break;
int idx = line.indexOf( '=' );
String key = line.substring( 0, idx );
String value = line.substring( idx+1 );
hash.put( key, value );
System.out.println( key + " = " + value );
The other solution is to send the result of the SET command to file and then read the file from Java. ...
if (OS.indexOf("windows 9") > -1) {
p = r.exec( "command.com /c set > envvar.txt" );
else if ( (OS.indexOf("nt") > -1)
|| (OS.indexOf("windows 2000") > -1
|| (OS.indexOf("windows xp") > -1) ) {
// thanks to JuanFran for the xp fix!
p = r.exec( "cmd.exe /c set > envvar.txt" );
// then read back the file
Properties p = new Properties();
p.load(new FileInputStream("envvar.txt"));
Thanks to JP Daviau
// UNIX
public Properties getEnvironment() throws java.io.IOException {
Properties env = new Properties();
env.load(Runtime.getRuntime().exec("env").getInputStream());
return env;
Properties env = getEnvironment();
String myEnvVar = env.get("MYENV_VAR");
To read only one variable : // NT version , adaptation for other OS is left as an exercise...
Process p = Runtime.getRuntime().exec("cmd.exe /c echo %MYVAR%");
BufferedReader br = new BufferedReader
( new InputStreamReader( p.getInputStream() ) );
String myvar = br.readLine();
System.out.println(myvar);
Java's System properties contains some useful informations about the environment, for example, the TEMP and PATH environment variables (on Windows). public class ShowSome {
public static void main(String args[]){
System.out.println("TEMP : " + System.getProperty("java.io.tmpdir"));
System.out.println("PATH : " + System.getProperty("java.library.path"));
System.out.println("CLASSPATH : " + System.getProperty("java.class.path"));
System.out.println("SYSTEM DIR : " +
System.getProperty("user.home")); // ex. c:\windows on Win9x system
System.out.println("CURRENT DIR: " + System.getProperty("user.dir"));
Here some tips from H. Ware about the PATH on different OS.
PATH is not quite the same as library path. In unixes, they are completely different---the libraries typically have their own directories. System.out.println("the current value of PATH is: {" +
p.getProperty("PATH")+"}");
System.out.println("LIBPATH: {" +
System.getProperty("java.library.path")+"}");
gives the current value of PATH is:
{/home/hware/bin:/usr/local/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/ccs/bin:
/usr/ucb:/bin:/usr/bin:/home/hware/linux-bin:/usr/openwin/bin/:/usr/games/:
/usr/local/games:/usr/ccs/lib/:/usr/new:/usr/sbin/:/sbin/:/usr/hosts/:
/usr/openwin/lib:/usr/X11/bin:/usr/bin/X11/:/usr/local/bin/X11:
/usr/bin/pbmplus:/usr/etc/:/usr/dt/bin/:/usr/lib:/usr/lib/lp/postscript:
/usr/lib/nis:/usr/share/bin:/usr/share/bin/X11:
/home/hware/work/cdk/main/cdk/../bin:/home/hware/work/cdk/main/cdk/bin:.}
LIBPATH:
{/usr/lib/j2re1.3/lib/i386:/usr/lib/j2re1.3/lib/i386/native_threads:
/usr/lib/j2re1.3/lib/i386/client:/usr/lib/j2sdk1.3/lib/i386:/usr/lib:/lib}
on my linux workstation. (java added all those execpt /lib and /usr/lib). But these two lines aren't the same on window either:
This system is windows nt the current value of PATH is:
{d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;c:\depot\cdk\main\cdk\bin;c:\depot\
cdk\main\cdk\..\bin;d:\OrbixWeb3.2\bin;D:\Program
Files\IBM\GSK\lib;H:\pvcs65\VM\win32\bin;c:\cygnus
\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;D:\orant\bin;C:\WINNT\system32;C:\WINNT;
C:\Program Files\Dell\OpenManage\Resolution Assistant\Common\bin;
d:\Program Files\Symantec\pcAnywhere;
C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}
LIBPATH:
{D:\jdk1.3\bin;.;C:\WINNT\System32;C:\WINNT;d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;
c:\depot\cdk\main\cdk\bin;c:\depot\cdk\main\cdk\..\bin;
d:\OrbixWeb3.2\bin;D:\Program Files\IBM\GSK\lib;
H:\pvcs65\VM\win32\bin;c:\cygnus\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;
D:\orant\bin;C:\WINNT\system32;
C:\WINNT;C:\Program Files\Dell\OpenManage\ResolutionAssistant\Common\bin;
d:\Program Files\Symantec\pcAnywhere;
C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce} -
Reading Operationg System Environment Variables
How can i read Operating System environment variables for examples in Windows without using java -D option
just to simply get the value from windows enviroment variables settings... such as "MyApp"
is there a way i can get the value using java???
need something that is backward compatible ... like between jdk version 1.2.2 to 1.3.1???
help...
:~(
Thanks in Advance,
CheahSome ugly hack like using Runtime.getRuntime().exec("echo %wasteoftime%") and examining its output might work.
-
Setting persitent system environment variables using java program
hai,
Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
BijuThe solution I proposed worked only on Windows XP/2003.
The following solution will work on Windows NT/2000/XP/2003 with JDK 1.2+.
1- Download the [url http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip]JNIRegistry zipped archive.
2- Open the registry-3.1.3.zip file and extract in the folder of your choice ( Eg. c:\setenv ) only the 2 first files (when sorted by path): ICE_JNIRegistry.dll and registry.jar.
You don't need to keep the folder tree in the extraction.
3- Create the following SetEnv.java file in the same folder ( Eg. c:\setenv ).
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryKey;
import com.ice.jni.registry.RegStringValue;
import com.ice.jni.registry.RegistryValue;
public class SetEnv
static final String REG_HKLM_SUBKEY_NAME = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
public static void main(String[] args)
throws Exception
new SetEnv().exec(args);
void exec(String[] args)
throws Exception
if (args.length != 2)
throw new IllegalArgumentException("\n\nUsage: java SetEnv {varName} {varValue}\n\n");
String varName = args[0];
String varValue = args[1];
RegistryKey key = null;
RegStringValue value;
try
key = Registry.HKEY_LOCAL_MACHINE.openSubKey(REG_HKLM_SUBKEY_NAME, RegistryKey.ACCESS_ALL);
value = new RegStringValue(key, varName, RegistryValue.REG_EXPAND_SZ);
value.setData(varValue);
key.setValue(value);
key.flushKey();
finally
try { key.closeKey(); }
catch (Exception e) {}
}4- Compile it.
javac -classpath .;registry.jar SetEnv.java
5- Run it. varName and varValue are strings of your choice.
java -classpath .;registry.jar -Djava.library.path=. SetEnv varName varValue -
Using Bind variables in SQL PLUS Report
using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
error: Bind Variable "ENDING_DATE" not declared
Report Date and Time:
26-OCT-2010 15:44:13
List of Unapproved Adjustments
Bind Variable 'ENDING_DATE" not declared
Please see below the code for the sql plus report:
define p_org_id = '&1'
define p_fy_begin_date = '&2'
define p_start_date = '&3'
define p_end_date = '&4'
define p_conversion = '&5'
declare
variable begin_date date;
exec :begin_date := p_start_date;
variable ending_date date;
exec :ending_date := p_end_date;
/* Begin
:begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
:ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
End; */
set newpage none
set termout off
set pagesize 55
set linesize 180
set heading on
set feedback off
set wrap off
set space 1
set heading on
begin
dbms_application_info.set_client_info('&p_org_id');
end;
prompt
prompt Report Date and Time:
prompt ----------------------
select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
from dual ;
prompt
prompt List of Unapproved Adjustments
prompt -------------------------------
select b.trx_number,
a.adjustment_number,
f.user_name created_by
from apps.ar_adjustments a,
apps.ra_customer_trx b,
apps.fnd_user f
where a.customer_trx_id = b.customer_trx_id
and a.status <> 'A'
and a.created_by = f.user_id
and a.creation_date between :begin_date
and :ending_date
-- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
-- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
order by
b.trx_number ;Hi
Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
vishnu
null -
Windows - PERL5LIB Environment variables
Hi All,
I was trying out xampp and I removed the perl5lib environment variables for Oracle. Unfortunately, I did not save the settings in notepad or something and yes, I know how stupid that was. Consequently, now all the clients are failing on that server. For example, if I click on SQL*Plus, I get the "Need to set ORACLE_HOME" error (same thing for PHP, etc.).
I would really appreciate it if someone can send me their PATH and PERL5LIB environment variables from a Windows (preferrably XP) installation of Oracle. Also, is there some other way to restore these values? Like a bat file or something that gets installed. Thanks a lot.Hi. Thank you for your response. I tried rebooting, but I still get the error.
Like I said, the only change I made was to the environment variables. It is possible that xampp made some changes behind the scenes, but the only known change was me replacing the Oracle PERL paths with the xampp PERL paths in the Windows environment variables (through "My Computer" --> "Properties").
Is it possible to do a re-configuration using the installer instead of a complete re-install? If you have any other ideas, I would appreciate it. Thanks. -
Backing Up System Environment Variables
How do I backup system variables on a Windows machine? Are HYPERION_HOME and EPM_ORACLE_HOME system variables the same?
If this is windows then I find the best way is to either backup the registry or part of the registry, environment variables are stored in the registry at :-
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
So if you go to start > run > regedit > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment > right click export, it will save it out to a registry file.
The registry can also be exported from command line , for example go to a command prompt and type
REG EXPORT /?
Cheers
John
http://john-goodwin.blogspot.com/ -
Using variables in SQL Plus Worksheet
I'm new to Oracle. I've developed in MS SQL for some time. I'm trying to debug a query we're using in an application. I paste it into SQL Plus Worksheet and get the message:
SP2-0552: Bind variable "COUNTYPK" not declared.
I could paste in a value, but I would like to define a variable before the query so that it will work the same way as it would in production.
SELECT rsiplate.OWNER.work_area_code || '-' || SUBSTR(rsiplate.OWNER.work_phone_number, 1, 3) || '-' || SUBSTR(rsiplate.OWNER.work_phone_number, 4, 4) AS BUSINESSPHONE, trim(rsiplate.OWNER.first_name||' '||rsiplate.OWNER.middle_name||' '||rsiplate.OWNER.last_name) AS BUSINESSNAME, rsiplate.ADDRESS.address_line1 AS ADDRESSLINE1, rsiplate.ADDRESS.address_line2 AS ADDRESSLINE2, rsiplate.ADDRESS.city_name AS CITY, rsiplate.ADDRESS.state_code AS STATE, SUBSTR(rsiplate.ADDRESS.zip_code, 1, 5) AS POSTALCODE FROM rsiplate.WATERCRAFT_MASTER, rsiplate.WATERCRAFT_CURRENT, rsiplate.WATERCRAFT_REGIST_CURRENT, rsiplate.OWNER, rsiplate.WATERCRAFT_OWNER_CURRENT, rsiplate.ADDRESS WHERE rsiplate.WATERCRAFT_MASTER.WATERCRAFT_ID = rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_ID AND rsiplate.WATERCRAFT_MASTER.LF_WATERCRAFT_REGIST_ORDER = rsiplate.WATERCRAFT_REGIST_CURRENT.WATERCRAFT_REGIST_ORDER AND rsiplate.WATERCRAFT_MASTER.LF_WATERCRAFT_ORDER = rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_ORDER AND rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_REGIST_CURRENT.watercraft_id and rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_id and rsiplate.WATERCRAFT_OWNER_CURRENT.owner_id = rsiplate.OWNER.owner_id and rsiplate.WATERCRAFT_MASTER.watercraft_owner_group = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_group and rsiplate.ADDRESS.address_set_id = rsiplate.OWNER.address_set_id and rsiplate.WATERCRAFT_MASTER.data_status_code = 1 and rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_order = 1 and rsiplate.WATERCRAFT_REGIST_CURRENT.REGIST_EXPIRATION_DATE >= SYSDATE AND rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_USE_CODE = 3 AND rsiplate.ADDRESS.COUNTY_NUMBER = :CountyPK GROUP BY rsiplate.OWNER.work_area_code, rsiplate.OWNER.work_phone_number, rsiplate.OWNER.first_name, rsiplate.OWNER.middle_name, rsiplate.OWNER.last_name, rsiplate.ADDRESS.address_line1, rsiplate.ADDRESS.address_line2, rsiplate.ADDRESS.city_name, rsiplate.ADDRESS.state_code, rsiplate.ADDRESS.zip_code;Okay, I made some adjustements:
SET DEFINE :
DEFINE :COUNTYPK = '01'
SELECT rsiplate.OWNER.work_area_code||'-'||SUBSTR(rsiplate.OWNER.work_phone_number, 1, 3)||'-'||SUBSTR(rsiplate.OWNER.work_phone_number, 4, 4) AS BUSINESSPHONE, trim(rsiplate.OWNER.first_name||' '||rsiplate.OWNER.middle_name||' '||rsiplate.OWNER.last_name) AS BUSINESSNAME, rsiplate.ADDRESS.address_line1 AS ADDRESSLINE1, rsiplate.ADDRESS.address_line2 AS ADDRESSLINE2, rsiplate.ADDRESS.city_name AS CITY, rsiplate.ADDRESS.state_code AS STATE, SUBSTR(rsiplate.ADDRESS.zip_code, 1, 5) AS POSTALCODE FROM rsiplate.WATERCRAFT_MASTER, rsiplate.WATERCRAFT_CURRENT, rsiplate.WATERCRAFT_REGIST_CURRENT, rsiplate.OWNER, rsiplate.WATERCRAFT_OWNER_CURRENT, rsiplate.ADDRESS WHERE rsiplate.WATERCRAFT_MASTER.WATERCRAFT_ID = rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_ID AND rsiplate.WATERCRAFT_MASTER.LF_WATERCRAFT_REGIST_ORDER = rsiplate.WATERCRAFT_REGIST_CURRENT.WATERCRAFT_REGIST_ORDER AND rsiplate.WATERCRAFT_MASTER.LF_WATERCRAFT_ORDER = rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_ORDER AND rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_REGIST_CURRENT.watercraft_id and rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_id and rsiplate.WATERCRAFT_OWNER_CURRENT.owner_id = rsiplate.OWNER.owner_id and rsiplate.WATERCRAFT_MASTER.watercraft_owner_group = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_group and rsiplate.ADDRESS.address_set_id = rsiplate.OWNER.address_set_id and rsiplate.WATERCRAFT_MASTER.data_status_code = 1 and rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_order = 1 and rsiplate.WATERCRAFT_REGIST_CURRENT.REGIST_EXPIRATION_DATE >= SYSDATE AND rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_USE_CODE = 3 AND rsiplate.ADDRESS.COUNTY_NUMBER = :CountyPK GROUP BY rsiplate.OWNER.work_area_code, rsiplate.OWNER.work_phone_number, rsiplate.OWNER.first_name, rsiplate.OWNER.middle_name, rsiplate.OWNER.last_name, rsiplate.ADDRESS.address_line1, rsiplate.ADDRESS.address_line2, rsiplate.ADDRESS.city_name, rsiplate.ADDRESS.state_code, rsiplate.ADDRESS.zip_code;
But I still get this:
SP2-0317: expected symbol name is missing
old 2: iplate.WATERCRAFT_REGIST_CURRENT.watercraft_id and rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_id and rsiplate.WATERCRAFT_OWNER_CURRENT.owner_id = rsiplate.OWNER.owner_id and rsiplate.WATERCRAFT_MASTER.watercraft_owner_group = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_group and rsiplate.ADDRESS.address_set_id = rsiplate.OWNER.address_set_id and rsiplate.WATERCRAFT_MASTER.data_status_code = 1 and rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_order = 1 and rsiplate.WATERCRAFT_REGIST_CURRENT.REGIST_EXPIRATION_DATE >= SYSDATE AND rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_USE_CODE = 3 AND rsiplate.ADDRESS.COUNTY_NUMBER = :CountyPK GROUP BY rsiplate.OWNER.work_area_code, rsiplate.OWNER.work_phone_number, rsiplate.OWNER.first_name, rsiplate.OWNER.middle_name, rsiplate.OWNER.last_name, rsiplate.ADDRESS.address_line1, rsiplate.ADDRESS.address_line2, rsiplate.ADDRESS.city_name, rsiplate.ADDRESS.state_code, rsiplate.ADDRESS.zip_code
new 2: iplate.WATERCRAFT_REGIST_CURRENT.watercraft_id and rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_id and rsiplate.WATERCRAFT_OWNER_CURRENT.owner_id = rsiplate.OWNER.owner_id and rsiplate.WATERCRAFT_MASTER.watercraft_owner_group = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_group and rsiplate.ADDRESS.address_set_id = rsiplate.OWNER.address_set_id and rsiplate.WATERCRAFT_MASTER.data_status_code = 1 and rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_order = 1 and rsiplate.WATERCRAFT_REGIST_CURRENT.REGIST_EXPIRATION_DATE >= SYSDATE AND rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_USE_CODE = 3 AND rsiplate.ADDRESS.COUNTY_NUMBER = 01 GROUP BY rsiplate.OWNER.work_area_code, rsiplate.OWNER.work_phone_number, rsiplate.OWNER.first_name, rsiplate.OWNER.middle_name, rsiplate.OWNER.last_name, rsiplate.ADDRESS.address_line1, rsiplate.ADDRESS.address_line2, rsiplate.ADDRESS.city_name, rsiplate.ADDRESS.state_code, rsiplate.ADDRESS.zip_code
iplate.WATERCRAFT_REGIST_CURRENT.watercraft_id and rsiplate.WATERCRAFT_MASTER.watercraft_id = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_id and rsiplate.WATERCRAFT_OWNER_CURRENT.owner_id = rsiplate.OWNER.owner_id and rsiplate.WATERCRAFT_MASTER.watercraft_owner_group = rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_group and rsiplate.ADDRESS.address_set_id = rsiplate.OWNER.address_set_id and rsiplate.WATERCRAFT_MASTER.data_status_code = 1 and rsiplate.WATERCRAFT_OWNER_CURRENT.watercraft_owner_order = 1 and rsiplate.WATERCRAFT_REGIST_CURRENT.REGIST_EXPIRATION_DATE >= SYSDATE AND rsiplate.WATERCRAFT_CURRENT.WATERCRAFT_USE_CODE = 3 AND rsiplate.ADDRESS.COUNTY_NUMBER = 01 GROUP BY rsiplate.OWNER.work_area_code, rsiplate.OWNER.work_phone_number, rsiplate.OWNER.first_name, rsiplate.OWNER.middle_name, rsiplate.OWNER.last_name, rsiplate.ADDRESS.address_line1, rsiplate.ADDRESS.address_line2, rsiplate.ADDRESS.city_name, rsiplate.ADDRESS.state_code, rsiplate.ADDRESS.zip_code
ERROR at line 2:
ORA-00933: SQL command not properly ended -
How to bind DATE variables in SQL*Plus
I have a stored procedure in a package that has a DATE OUT parameter
myPackage.myProcedure( outDate OUT DATE )
I am trying to test this from SQL*Plus
How do I specify a Bind variable for the outDate? The VARIABLE command does not allow DATE types?
If this was a CHAR type I could have done
VARIABLE myChar CHAR
BEGIN
myPackage.myProcedure( :myChar )
END;
PRINT myChar
How do I do this with DATE data types instead? I am using Oracle 8.1.7.you should use VARCHR2 type with the minimum length that can store a value defined by your NLS_DATE_FORMAT
string. The returned date will be converted to a VARCAHR2 type and the size and format will depend on
your NLS_DATE_FORMAT setting.
=============================================================================
SQL> variable dt VARCHAR2(20)
SQL> create or replace procedure ret_date(dt OUT DATE) is
2 begin
3 dt := SYSDATE ;
4 end ;
5 /
Procedure created.
SQL> exec ret_date(:dt) ;
PL/SQL procedure successfully completed.
SQL> print dt
DT
13-OCT-02
SQL> select sysdate from dual ;
SYSDATE
13-OCT-02
SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS' ;
Session altered.
SQL> exec ret_date(:dt) ;
PL/SQL procedure successfully completed.
SQL> print dt
DT
13-OCT-2002 10:43:23
SQL>
================================================================ -
Substitution variables in Sql*Plus
Hi all,
How to make Sql*Plus ask for the substitution variable value one time only for a substitution variable even if it appears multiple times inside a query ? Because so far each time I launched the query below then I have been asked two times by Sql*Plus for the variable value. For example : select ref_site from t_comsis where longitude_lamb + latitude_lamb < &distance + power(&distance,2).
Thanksof course accept is more friendly, you can check for valid number, you can have a prompt or a hidden input.
you can also undef your variable if you prefer the && solution
SQL> select &&x+&&x from dual;
Enter value for x: 1
old 1: select &&x+&&x from dual
new 1: select 1+1 from dual
1+1
2
SQL> undef x
SQL> r
1* select &&x+&&x from dual
Enter value for x: 2
old 1: select &&x+&&x from dual
new 1: select 2+2 from dual
2+2
4 -
many times, i am confused by the way to assess a variable defined in sql*plus. can someone give a clear explanation on the difference and when to use which?
&var, &&var, :varnot sure if this will help
SQL> define vDepNo = 20;
SQL> variable vDepNo number;
SQL> execute :vDepNo := &vDepNo;
PL/SQL procedure successfully completed.
SQL> select * from emp
2 where deptno = :vDepNo;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975 1000 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
SQL> select * from emp
2 where deptno = &&vDepNo;
old 2: where deptno = &&vDepNo
new 2: where deptno = 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975 1000 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
SQL> -
Hide new/old value of bind variable in SQL*Plus
Hi,
I have a SQL*Plus script to create a new user. It asks for username & password and then passes these values to a SP to do some checks and finally create the user.
The output is currently the following :
New user will be created in ORCL LAB
Enter the requested username : fleet2
Enter the password for fleet2 : *****
Re-enter the password for fleet2 : *****
old 2: labadmin_cr_user('&username', '&pswd', '&pswd2');
new 2: labadmin_cr_user('fleet2', 'fleet', 'fleet');
The requested username is already in use in the database. Please choose another username.
As you can see the passwords are now exposed when the procedure is called. This is not what I want off course. I cannot do termout off as the serveroutput is not shown as well in that case. I use dbms_output to show error messages to users. (see example above in case of an existing user).
Can anybody tell me how to hide these 2 lines (old 2, new 2) without hiding my dbms_output.
Thanks!
Krisset verify offhttp://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013382
Maybe you are looking for
-
Upgrading SAP ESS and MSS after HR upgrade in ECC 6.0
Hello I am new to SAP netweaver. Our landscape has an ECC 6.0 system integrated with EP 7.0. We recently upgraded our SAP HR from 600(SP 48) to 600(SP61) and EA HR component from 603(SP 22) to 603( SP 35). After the upgrade we came to know that the p
-
UDPClient socket.receive() problem
I have a slight problem.... while receiving the packets..... /*** DECLARE AND INSTANCIATE DATAGRAM TO RECEIVE ***/ /* buffer for holding the incoming datagram*/ byte[] buffer = new byte[size]; Datagr
-
PSE 5.0 Organizer malfunction
Today, out of the blue, PSE would not lauch at all. Eventually I was able to get the Editor to launch, but not the Organizer. I can now get the organizer to launch through the Editor, but only if I hold down the control key and create a new catalog.
-
Exportfunktion von Bridge speichert alles in srgb
Es um die Exportfunktion von Bridge. Hier ziehe ich die Bilder hin, die später zur Entwicklung oder zum Drucker sollen. Egal ob die Bilder in Camera Raw mit Farbraum Adobe RGB, als TIF in Adobe RGB oder sofern Schwarzweiß in Gamma 2.2 vorliegen, habe
-
HELP!! REMOVE ITUNES.
okay, this is really ********. Before i was unable to install itunes so i had to remove all the files from my laptop to install it again, but when i was removing everything it would not let me remove the itunes icon so up till now it's some damaged f