oracle11g – Oracle 11 – sqlplus – 回滚整个剧本的错误 –
发布时间:2021-01-17 00:47:49 所属栏目:站长百科 来源:网络整理
导读:如安在包括的SQL文件中的任何错误上使Oracle 11g回滚整个事宜? 文件内容是: set autocommit offwhenever SQLERROR EXIT ROLLBACKinsert into a values (1);insert into a values (2);drop index PK_NOT_EXIST;commit; 并行使“@”将文件包括在sqlplus会话
如安在包括的SQL文件中的任何错误上使Oracle 11g回滚整个事宜? 文件内容是: set autocommit off whenever SQLERROR EXIT ROLLBACK insert into a values (1); insert into a values (2); drop index PK_NOT_EXIST; commit; 并行使“@”将文件包括在sqlplus会话中: @error.sql 正如预期的那样,sqlplus会话终止,输出竣事 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 可是当我从头启动sqlplus时,表a包括2笔记录,这意味着在退出sqlplus时有一个提交而不是回滚. 我可以以某种方法逼迫sqlplus: >堕落时遏制处理赏罚文件, 办理要领DDL在运行之前和之后执行提交,这样纵然您的DDL失败,oracle也已经提交了事宜.你可以办理它: set autocommit off whenever SQLERROR EXIT ROLLBACK declare procedure drop_idx(i varchar2) is pragma autonomous_transaction; -- this runs in its own transaction. begin execute immediate 'drop index ' || i; end; begin insert into a values (1); insert into a values (2); drop_idx('PK_NOT_EXIST'); end; / (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |