How to return an error code to SQL*Plus from PL/SQL procedure
812115Nov 25 2010 — edited Jun 16 2011Hi,
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.