Saya percaya wayang mendeteksi keberhasilan skrip berdasarkan kode pengembalian dari program yang dipanggil. Secara default, sqlplus mengembalikan 0 saat Anda menutupnya, terlepas dari apa yang mungkin telah dijalankan selama sesi.
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 17 08:47:08 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select asdjkhasd from sadbjaksd;
select asdjkhasd from sadbjaksd
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] ~]$ echo $?
0
Jika Anda ingin sqlplus keluar dengan status kesalahan, Anda dapat menggunakan perintah when, mis.
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 17 08:48:17 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> whenever sqlerror exit failure;
SQL> select bogus from nowhere;
select bogus from nowhere
*
ERROR at line 1:
ORA-00942: table or view does not exist
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] ~]$ echo $?
1
Perhatikan kode pengembalian yang berbeda dalam kasus terakhir. Ini seharusnya cukup untuk memberi tahu boneka bahwa perintahnya gagal.