i'm having real problems retrieving the returncode of my sqlplus-call. I found a lot of informations on the net, but havn't been able to get it running so far, so now i ask for some help
I do start the sqlplus out of my shell script with the parameters stored in the proc_clips.sql, which is perfectly working. But now i have created some real obviously mistakes like "trunate" or "comit" - but I still get the 0 as returncode. Does anybody have an idea what i'm doing wrong???
For this reason, I suggest you exiting with a good return status different from 0, and test this value for successful completion of the sql script.
Every exit status is good, only dont' use 0
Here at work we have a whole bunch of sql programs made in this way for avoiding this problem.
He's using whenever sql/os error, so if
there is a SQL, PL/SQL or OS error, it's handled before the final exit:
$ sqlplus -s '/ as sysdba'<<<$(printf "whenever sqlerror exit 42\nselect 'hello' from x;\nexit 0")||echo "exit status $?"
select 'hello' from x
*
ERROR at line 1:
ORA-00942: table or view does not exist
exit status 42
It's about the syntax errors that are not handled by the whenever directive.