Home » Infrastructure » Unix » validation of the script in oracle when logging from shell script
validation of the script in oracle when logging from shell script [message #98231] Thu, 20 May 2004 02:30 Go to next message
Jagan
Messages: 11
Registered: October 2001
Junior Member
Hi.

I am new to UNIX.

I am executing a script in oracle by using the following in a shell script

sqlplus test/test@db01 @update.sql

exit 0

My requirement is to exit with a different number if the script file is missing in that directory or if unable to connect to oracle

Please give a solution

Thanks in Advance

Note: I apologise if I am posting this question again.. I am new to this forum also. Pl give the link if this has been answered already

 

 
Re: validation of the script in oracle when logging from shell script [message #98235 is a reply to message #98231] Thu, 20 May 2004 09:08 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
1.) before calling sqlplus remove flag file (see#3) if present
2.) in sql script, include whenever sqlerror and oserror (not sure if you'll need these)
3.) at the bottom of your sql script, include something like:
spool update_emp_flag_file.log
spool off
4.) After finishing sql and returning to shell script, check for flag file. If not found then error...
Re: validation of the script in oracle when logging from shell script [message #98250 is a reply to message #98231] Fri, 28 May 2004 09:20 Go to previous message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
In unix, you can check to see whether a file is present like this :-

if test -e update.sql
then
echo "file exists"
else
echo "Error: File not found."
fi

It is the '-e' that instructs 'test' to check whether the file exists. There are other switches to check that the file is readable by the current user . . .

Many unixs have extended syntax for doing 'if's which do not require the 'test' command, and are therefore more efficient.

Takmeister
Previous Topic: Search a string in a folder
Next Topic: Need Help!
Goto Forum:
  


Current Time: Thu Mar 28 11:13:22 CDT 2024