How can I get Oracle 11g to cancel the entire transaction if there is any error in the included SQL file?
File contents:
set autocommit off whenever SQLERROR EXIT ROLLBACK insert into a values (1); insert into a values (2); drop index PK_NOT_EXIST; commit;
And the file is included in the sqlplus session using "@":
@error.sql
As expected, the sqlplus session ends and the exit
SQL> @error.sql 1 row created. 1 row created. drop index PK_NOT_EXIST * ERROR at line 1: ORA-01418: specified index does not exist Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
But when I restart sqlplus, then table a contains 2 records, which means that when sqlplus exited it was commit , not rollback.
Is there any way to force sqlplus:
- stop processing the file on error,
- and rollback of the entire transaction on error?
source share