存储过程内嵌存储过程时,子过程事务提交会影响父存储过程事务提交,会将子存储过程前面的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记录
本文探讨了在存储过程中嵌套子存储过程时,子存储过程的事务提交如何影响父存储过程的事务。子存储过程的提交会提交其前面的DML操作,但不包括后面的。通过示例protest01和protest02进行验证。
1999

被折叠的 条评论
为什么被折叠?



