Home » Infrastructure » Unix » Execute Oracle procedure from UNIX prompt
Execute Oracle procedure from UNIX prompt [message #109842] Tue, 01 March 2005 02:51 Go to next message
shahaness
Messages: 8
Registered: July 2004
Junior Member
I want to execute a Oracle procedure from UNIX script.
I hv written the following in the script file(.SH file):
-----------------------------------------
sqlplus newclsdev/newclsdev@aurdb;
//Execute the procedure which does something and commits

exec test_i();
exit;
-----------------------------------------
Problem -
This script just connects to oracle and stops aat the
sql prompt.
I want to execute the procedure and come back to UNIX prompt again.i.e exec and exit should work.
But it is not happening.
Pl. help.

Thanks
Re: Execute Oracle procedure from UNIX prompt [message #109844 is a reply to message #109842] Tue, 01 March 2005 07:05 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
You can use the command line switch @somescript.sql (when calling sql*plus) to execute this somescript.sql file. In this file, you place your SQL script .

E.g. from a DOS box:
sqlplus scott/tiger@somedb @somescript.sql



MHE
icon7.gif  Re: Execute Oracle procedure from UNIX prompt [message #109961 is a reply to message #109844] Wed, 02 March 2005 06:35 Go to previous messageGo to next message
shahaness
Messages: 8
Registered: July 2004
Junior Member
Cool
Thanks . It worked
Re: Execute Oracle procedure from UNIX prompt [message #109987 is a reply to message #109961] Wed, 02 March 2005 10:48 Go to previous message
scott.swank
Messages: 14
Registered: March 2005
Location: Las Vegas
Junior Member
Note that anyone who runs "ps -ef | grep sqlplus" on the same Unix box will see that your password is tiger as long as your sqlplus session is running. You can do things like:

echo tiger | sqlplus scott@your_database @your_script

And then the password is provided to sqlplus via a friendly pipe that is not externally visible. There are other options (os credentials, for example), but this at least gives you one option that is somewhat secure.
Previous Topic: Solaris: Change of domain name
Next Topic: Urgent require shell script to read a flat file
Goto Forum:
  


Current Time: Sat Jan 16 12:16:25 CST 2021