-
whenever oserror exit
Bonjour à tous,
sqlplus /nolog <<EOF
spool
whenever sqlerror exit 1;
whenever oserror exit 2;
connect user/pass
reqête.sql
spool off
exit 0;
EOF
En cas d'erreur sur la requête.sql (erreur car la clause where ne colle pas avec la table par exemple ...) j'ai un code retour=2 et non pas 1, est ce normal ? on est en 9i.
Par avance Merci.
-
Non ça n'est pas normal, es-tu sûr de ton code retour et de ton erreur.
Exemple :
promp unix>cat test.sh
sqlplus /nolog <<EOF
spool
whenever sqlerror exit 1;
whenever oserror exit 2;
connect nosica
select * from dba_tables
where MAFCOL='TOTO'
/
spool off
exit 0;
EOF
promp unix> test.sh
SQL*Plus: Release 9.2.0.7.0 - Production on Thu Apr 17 15:28:30 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> not spooling currently
SQL> SQL> SQL> Enter password:
ERROR:
ORA-01005: null password given; logon denied
promp unix> echo $?
1
-
prompt unix> cat test.sh
sqlplus /nolog <<EOF
spool
whenever sqlerror exit 1;
whenever oserror exit 2;
connect user/pwd
select * from dba_tables
where MAFCOL='TOTO'
/
spool off
exit 0;
EOF
prompt unix> test.sh
SQL*Plus: Release 9.2.0.7.0 - Production on Thu Apr 17 15:31:04 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> not spooling currently
SQL> SQL> SQL> Connected.
SQL> SQL> 2 3 where MAFCOL='TOTO'
*
ERROR at line 2:
ORA-00904: "MAFCOL": invalid identifier
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production
prompt unix> echo $?
1
-