I am facing an issue in capturing the return code of a stored procedure. I am calling a sybase stored procedure in my korn shell script using isql statement as mentioned below.
isql -U ${APPLID} -S{SERVER}> ${sqlMsg} << EOF
use ${DATABASE}
go
exec stored_procedure
go
EOF
returncode=$?
If an error occur inside the stored procedure, I am not able to capture if I follow the below method.
if [ $returncode -ne 0 ]
then
print "failed"
fi
I tried using a return statement inside the stored procedure like
return (1)
but this didn't give me expected results. When i echoed the returncode, it echoed as 0, even after returning the status as 1. return status as 1 was seen in the sql logs.