以下来自doc:的声明是否有效?
如果退出存储的具有未处理异常的子程序,PL / SQL不会为OUT参数赋值,也不会执行任何回滚
根据声明ROLLBACK
不应该发生我的存储过程testy
引发未处理的异常。并且根据文档插入3,插入2应该成功,但没有插入成功。
create table mytable (num int not null primary key);
insert into mytable values(1);
create or replace procedure testy is
begin
insert into mytable values(2);
insert into mytable values(1); //throws error: ORA-00001: unique constraint (SRISRI1.SYS_C0011447) violated
end;
create or replace procedure testp is
begin
insert into mytable values(3);
testy;
insert into mytable values(4);
end;
exec testp;
select * from mytable;
mytable
_______
1
我们在你的previous topic讨论过它,不是吗?
威廉罗伯逊说:
您可以将整个匿名块视为单个DML语句。如果失败,它会回滚到自己的开始,就像更新等一样。
Oracle执行了隐式回滚并恢复了INSERT 2和INSERT 3,它返回到起始点,即返回到执行TESTP过程之前的情况,表中的值为1。