
prompt
prompt 创建表eoda.t
declare 
    num   number;
begin
    select count(1) into num from user_tables where table_name = upper( 't' );
    if num = 1 then 
        execute immediate 'drop table eoda.t';
    end if;
    execute immediate '
        create table eoda.t ( msg varchar2(25) )
    ';
end;
/

prompt
prompt 创建存储过程eoda.Autonomous_insert
create or replace procedure eoda.Autonomous_insert 
as 
    pragma    autonomous_transaction;
begin
    insert into eoda.t values ( 'Autonomous Insert' );
    commit;
end;
/

prompt
prompt 创建存储过程eoda.NonAutonomous_insert
create or replace procedure eoda.NonAutonomous_insert
as 
begin
    insert into eoda.t values ( 'NonAutonomous Insert' );
    commit;
end;
/

prompt
prompt 非自治事务eoda.NonAutonomous_insert 
begin
    insert into eoda.t values ( 'Anonymous Block' );
    NonAutonomous_insert;
    rollback;
end;
/

select * from eoda.t;

prompt
prompt 自治事务edoa.Autonomous_insert 
begin
    execute immediate 'truncate table eoda.t';
    insert into eoda.t values ( 'Anonymous Block' );
    Autonomous_insert;
    rollback;
end;
/

select * from eoda.t;
