在oracle中执行存储过程后是否发生任何自动提交? [英] Is there any auto commit happens after executing stored procedures in oracle?
问题描述
我在Oracle DB中有3个表.我正在编写一个过程,根据某些条件删除所有3个表中的某些行.
I have 3 tables in oracle DB. I am writing one procedure to delete some rows in all the 3 tables based on some conditions.
我在过程中一一使用了所有三个delete语句.在执行上述存储过程时,在执行时是否有任何自动提交发生?
I have used all three delete statements one by one in the procedure. While executing the mentioned stored procedure, is there any auto-commit happening in the at the time of execution?
否则,我是否需要在结束时手动编码提交?
Otherwise, Should I need to manually code the commit at the end?
推荐答案
在数据库级别没有自动提交,但是您使用的API可能具有自动提交功能. 来自汤姆·凯特(Tom Kyte).
There is no auto-commit on the database level, but the API that you use could potentially have auto-commit functionality. From Tom Kyte.
也就是说,我想补充:
Unless you are doing an autonomous transaction, you should stay away from committing directly in the procedure: From Tom Kyte.
节选:
我希望PLSQL不支持提交/回滚.我坚信 事务控制必须在最顶层的调用者级别进行.那 是您可以采用这N个存储过程并将其绑定的唯一方法 一起进行交易.
I wish PLSQL didn't support commit/rollback. I firmly believe transaction control MUST be done at the topmost, invoker level. That is the only way you can take these N stored procedures and tie them together in a transaction.
此外,还应该注意的是,对于DDL(基于您的问题,听起来好像您在过程中未执行任何DDL,而只是将其列为潜在陷阱),Oracle在此之前添加了隐式提交在DDL之后.
In addition, it should also be noted that for DDL (doesn't sound like you are doing any DDL in your procedure, based on your question, but just listing this as a potential gotcha), Oracle adds an implicit commit before and after the DDL.
这篇关于在oracle中执行存储过程后是否发生任何自动提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!