下面是个简单的测试,可以让大家更加清楚的明白自治事务和非自治事务的区别:
SQL> create table chris_test (name varchar2(200));
Table created.
SQL> create or replace PRocedure Autonomous_insert
2 as
3 pragma autonomous_transaction;
4 begin
5 insert into chris_test values ('Autonomous Insert!');
6 commit;
7 end;
8 /
Procedure created.
SQL> create or replace procedure Nonnomous_insert
2 as
3 begin
4 insert into chris_test values ('Nonnomous Insert!');
5 commit;
6 end;
7 /
Procedure created.
SQL> begin
2 insert into chris_test values ('Anonymous Block!');
3 Nonnomous_insert;
4 rollback;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> select * from chris_test;
NAME
------------------------------------------------
Anonymous Block!
Nonnomous Insert!
SQL> truncate table chris_test;
Table truncated.
SQL> begin
2 insert into chris_test values ('Anonymous Block!');
3 Autonomous_insert;
4 rollback;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> select * from chris_test;
NAME
----------------------------------------------
Autonomous Insert!
新闻热点
疑难解答