我有一个程序myProcedure
create or replace
procedure myProcedure as
begin
--some checking goes here
INSERT INTO table1 VALUES..
--some checking goes here
DELETE FROM table2;
end myProcedure;
我已调用此过程并且执行时没有任何错误。
我可以Rollback
此程序所做的更改吗?
答案 0 :(得分:0)
我猜你正在寻找SAVEPOINT。保存点保存事务状态并帮助回滚到指定的时间点。
create or replace
procedure myProcedure as
begin
--some checking goes here
INSERT INTO table1 VALUES..
SAVEPOINT my_savepoint;
--some checking goes here
DELETE FROM table2;
exception
WHEN DUP_VAL_ON_INDEX THEN
ROLLBACK TO do_insert;
DBMS_OUTPUT.PUT_LINE('Insert has been rolled back');
end myProcedure;
检查Oracle文档: