Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to return an error code to SQL*Plus from PL/SQL procedure

812115Nov 25 2010 — edited Jun 16 2011
Hi,

I want to be able to pass a variable back to the Unix script,and I have the following code

******************

sqlplus myuser/mypass << EOF
WHENEVER SQLERROR EXIT 41;
WHENEVER OSERROR EXIT 81;
execute pkonp.run_onp;
exit
EOF

ERRORCODE=$?

if [$ERRORCODE != 0] #test for successful onp
then
#Notify Administrator of ONP failure.
echo "ONP failure at `date`\n"
fi

******************
However, I am unable to get my PL/SQL to pass an error code back to SQL*Plus.

how do you trap an error in PL/SQL, and pass the error code to SQL*plus, so that SQL*Plus can then pass the error back to the Unix Shell script ?

Thank you very much.
This post has been answered by Billy Verreynne on Nov 25 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2011
Added on Nov 25 2010
5 comments
5,041 views