我只想问一下,是否应该在Oracle并发程序调用的PL/SQL过程中添加一个Commit?我一直认为在程序中提交提交是错误的做法,原因如下:
但是,我一直看到Oracle EBS开发人员将提交放在一个并发程序中。对此有什么想法吗?
谢谢!
发布于 2016-10-25 20:23:29
别担心,你做得对。数据库开发人员直到在生产中被烧掉,才会意识到很多事情。避免在代码中提交是为了使该代码能够与其他代码单元一起使用,而不会破坏整个系统逻辑。回滚不仅涉及异常,还涉及用户在交互程序中取消操作的自由,而不损坏数据库。
下面是一个例子,说明当一个开发人员(unit_2的开发人员)获得使用提交的自由时会发生什么。
create table t (i int);
create or replace procedure unit_1 as begin insert into t(i) values (1); end;
/
create or replace procedure unit_2 as begin insert into t(i) values (2); commit; end;
/
create or replace procedure unit_3 as begin insert into t(i) values (3); end;
/
create or replace procedure unit_4 as begin insert into t(i) values (4); end;
/
create or replace procedure all_units as begin delete t;unit_1;unit_2;unit_3;unit_4; end;
/
exec all_units;
select * from t;
I
----------
1
2
3
4
set transaction t; exec all_units; rollback;
select * from t;
I
----------
1
2
https://stackoverflow.com/questions/40248501
复制相似问题