在oracle函数中实现“全有或全无”原则 [英] implementing 'all or nothing' principle in an oracle function
问题描述
你好每个人
我有一个由多个代码块组成的oracle / plsql函数。每个块都在数据库表的特定部分进行修改。我需要将所有这些部分作为一个整体...要么全部执行要么全部执行(例如,在成功执行所有部分之前不会对表进行修改,否则如果出现某些错误或异常发生没有进行任何修改)。无论如何,DBMS会自动实现这个原则吗?
提前感谢...
hello every body
I have an oracle/plsql function consisting of multiple blocks of code. Each block makes modifications in a specific part of the database tables. I need to make all of those parts as a whole ... either it is executed all or none of it is executed (for example no modifications in the tables are done until all the parts are executed successfully , otherwise in case of some error or exception happens no modifications are done). Is there anyway to implement this principle automatically by the DBMS ?
thanks in advance ...
推荐答案
你所追求的是交易 [ ^ ]。你通常会开始一个事务,并做你需要做的所有事情:UPDATE,INSERT等等,只有在你完成并且一切都成功后你才能做出提交。如果在进程的任何阶段出现错误,您都会进行回滚,所有内容看起来都像是从未触及过。 :)
问候,
- Manfred 这里是另一个解释源提交和回滚:什么是提交和回滚? [ ^ ]
What you are after is Transactions[^]. You usually begin a transaction and do all the stuff you need to to do: UPDATE, INSERT etc. and only after you''re done and everything was successful you do a commit. In case of error at any stage in the process you do a rollback and everything looks as if you had never touched it. :)
Regards,
— Manfred Here another source that explaind Commit and Rollback: What is commit and rollback?[^]
这篇关于在oracle函数中实现“全有或全无”原则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!