I am actually calling an SQL script from Unix using the below code. The SQL script has millions of DML's which will be run on my database. The requirement is that if an DML fails then the script should abort with an exit code rather than skipping to the next DML. Currently,it is executing all the DML's without breaking at the DML that failed. We actually need more control on the script. How can we achieve this? Plz help.
SCRIPT BODY
#! /bin/sh
echo "Script started at `date`"
#************** Execute the extract sql on Staging database***************#
`sqlplus -s $CCBSTGID/$CCBSTGPASSWRD@$CCBSTGDBASE <<EOF
whenever sqlerror exit 2;
whenever error exit 3;
set termout on
set echo on
set serveroutput on
set pagesize 0
set linesize 500
set heading off
set verify on
set feedback on
spool output1.txt;
@DMLFile.sql
spool off;
quit;
EOF`
RC=$?
echo $RC
if [ ${RC} != 0 ]
then
echo "Script execution failed"
exit 1
fi
sqlplus <EOF ... EOFblock in back-ticks, or are you just unsure about S.O. formatting? As presented, the back-ticks provide no value.