Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture the return value of the oracle function in shell script

Status
Not open for further replies.

rk0000

Technical User
Mar 15, 2002
33
IN
I have a shell script like this:

sqlplus -s $USER/$PASS << ENDSQL #1> /dev/null 2>&1
set define off
set head off
whenever sqlerror exit sql.sqlcode
select fn_get_current_date_for_region('USA') from dual; ENDSQL

I want to capture the return value of the oracle function fn_get_current_date_for_region('USA') in the shell script. How can i do this?
Thanks...
 
in the shell script.. immediately following the execution of the script... do the following:

print $?
 
Dump your SQL into a separate script and call this from your original shell as a background process as such:

mysql& # call my SQL code
pid=$! # assign the process ID to variable &quot;pid&quot;
wait $pid # wait for the process to finish
echo &quot;$pid was terminated by a SIG$(kill -l $(($?-128))) signal&quot; # grab the exit code returned by wait

Take a look at the manpage for wait, it's all there for you!

ART
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top