Oracle Certification, Database Administration, SQL, Application, Programming Reference Books
Passing values back to unix script from sqlplus

Sometimes while calling sql scripts from shell scripts, it is required that you find out thatwhether the scripts failed or not. This is more imperative if you have a dependency between jobs. following is an example of this.

write following code in sql script
set echo on
whenever sqlerror exit 1
whenever oserror exit 2
--your code--
exit 0
write following code in shell script to receive the value
--call sql script
ret_val=$?
now ret val will have value 0 if sql script did not fail and 1 or 2 otherwise
 

Return to : Oracle Database, SQL, Application, Programming Tips