CREATE OR REPLACE procedure Test1
as
begin
--set transaction read write;
insert into aaa values(1);
commit;
end;
/
CREATE OR REPLACE procedure Test2
as
begin
--set transaction read write;
insert into aaa values(2);
Test1;
insert into aaa values(3);
rollback;
end;

 

運行結果aaa有兩個值1和2

 

自制事務的結果

CREATE OR REPLACE procedure Test1
as
PRAGMA AUTONOMOUS_TRANSACTION;
begin
--set transaction read write;
insert into aaa values(1);
commit;
end;
/
CREATE OR REPLACE procedure Test2
as
PRAGMA AUTONOMOUS_TRANSACTION;
begin
--set transaction read write;
insert into aaa values(2);
Test1;
insert into aaa values(3);
rollback;
end;

aaa中只有一個值1

posted on 2008-12-24 09:59  Oracle  阅读(335)  评论(0编辑  收藏  举报