Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Sqlplus and Unix : getting a non zero return code
I need to call in the experts. I would like to call sqlplus, pass sql
as a parm, run the sql and if there is a non zero return code exit the
script. The test script below does not seem to send the output to
correct output files.
Any help would be great...TIA
check_error() {
if [[ -a errfile ]]; then err_count=$(grep -c -e ^[^$] errfile) else err_count=0 fi if (( err_count > 0 )); then echo "\nErrors have been encountered. Please refer to errfile" fi
sqlplus -s > test.out 1>errfile 2>logfile <<EOF
username/pass
whenever sqlerror exit failure
set serveroutput on
spool outfile
select count(*) from table_name;
spool off;
exit;
EOF
RC=$?
if [[ $RC = 0 ]]; then
echo "Inside zero rc=$RC"
else
echo "Inside non-zero RC=$RC" exit -1
check_error Received on Mon Aug 20 2001 - 23:23:14 CDT