I have 2 shell scripts. One with data connection like that (script1.sh):
#!/usr/bin/ksh
query="$1"
whenever sqlerror exit 3
connect $user/$pass@sid
${query}
EOF
echo $?
if [ 0 -ne "$?" ];
then
exit 1
fi
And other is a shell script bigger where I execute sql commands like these:
#!/usr/bin/ksh
set -x
$PATH/script1.sh "
--set serveroutput on
--set feedback off
insert into table (column) values ('$1');
commit; "
if [[ $? != 0 ]]
then
echo "Error"
exit 3
else
echo "Ok"
fi
............
.............
.
The problem is that these second script won't detect error in sql commands and always continues with all code. I put traces and I check that rc is always 0. Could you help me to can detect errors if the sql failed? Thanks!