存储过程内嵌存储过程,子存储过程对父存储过程事务提交的影响

来源:互联网 发布:mac未能自动储存文稿 编辑:程序博客网 时间:2024/05/02 13:31

    存储过程内嵌存储过程时,子过程事务提交会影响父存储过程事务提交,会将子存储过程前面的DML语句一并提交,但不会提交后面DML语句。

    验证:

    父存储过程protest01

    create or replace procedure protest01(as_com_code varchar2) is    begin        insert into company(company_no) values('1001');        --protest02(as_com_code);        --execute immediate 'callprotest02('||as_com_code||')';        execute immediate 'call protest02(:1)'        using in as_com_code;        insert into company(company_no)values('1003');    end protest01;

  子存储过程protest02

    create or replace procedure protest02(as_com_code varchar2) is    begin        insert into company(company_no) values('1002');        commit;    end protest02;

   执行protest01

   sql>exec protest01('0001');

   未commit,此时数据库已经插入了1001、1002记录

 

 


0 0
原创粉丝点击