I have a KornShell (ksh) script that logins into SQL*Plus and executing a script. Within the shell script I would like to capture the status code of the SQL statement that
Exit from the sql file with
exit sql.sqlcode;
capture it in shell with $?
Have you tried using
whenever sqlerror exit sql.sqlcode
in your sql script? (also see this link)