oracle - Sql*plus always returns exit code 0? -
whenever run sql script using sql*plus , check $?, 0 when script wasn't succesful.
example
#$ sqlplus user/password@instance @script.sql sql*plus: release 10.2.0.1.0 - production on wed aug 7 14:20:44 2013 copyright (c) 1982, 2005, oracle. rights reserved. connected to: oracle9i enterprise edition release 9.2.0.8.0 - 64bit production partitioning, olap , oracle data mining options jserver release 9.2.0.8.0 - production v$dataf-ile d, * error @ line 6: ora-00933: sql command not ended disconnected oracle9i enterprise edition release 9.2.0.8.0 - 64bit production partitioning, olap , oracle data mining options jserver release 9.2.0.8.0 - production $ echo $? 0 $
i return non-zero value when error occurs.
how can achieve ?
you have explicitly tell sqlplus
that, in script. basically, there 2 statements can use:
whenever sqlerror exit sql.sqlcode
whenever oserror exit
for example:
whenever sqlerror exit sql.sqlcode begin select column_does_not_exist dual; end; /
and os errors:
whenever oserror exit failure start no_such_file
for more information, see this , that.
hope helps. luck!
Comments
Post a Comment