<bdo id='VOvjN'></bdo><ul id='VOvjN'></ul>
    <tfoot id='VOvjN'></tfoot>
  • <legend id='VOvjN'><style id='VOvjN'><dir id='VOvjN'><q id='VOvjN'></q></dir></style></legend>

      <small id='VOvjN'></small><noframes id='VOvjN'>

    1. <i id='VOvjN'><tr id='VOvjN'><dt id='VOvjN'><q id='VOvjN'><span id='VOvjN'><b id='VOvjN'><form id='VOvjN'><ins id='VOvjN'></ins><ul id='VOvjN'></ul><sub id='VOvjN'></sub></form><legend id='VOvjN'></legend><bdo id='VOvjN'><pre id='VOvjN'><center id='VOvjN'></center></pre></bdo></b><th id='VOvjN'></th></span></q></dt></tr></i><div id='VOvjN'><tfoot id='VOvjN'></tfoot><dl id='VOvjN'><fieldset id='VOvjN'></fieldset></dl></div>

        如何在 Oracle 中定义触发器 ON COMMIT?

        How to define a trigger ON COMMIT in Oracle?(如何在 Oracle 中定义触发器 ON COMMIT?)
          <tbody id='YvxtS'></tbody>

              <small id='YvxtS'></small><noframes id='YvxtS'>

              <i id='YvxtS'><tr id='YvxtS'><dt id='YvxtS'><q id='YvxtS'><span id='YvxtS'><b id='YvxtS'><form id='YvxtS'><ins id='YvxtS'></ins><ul id='YvxtS'></ul><sub id='YvxtS'></sub></form><legend id='YvxtS'></legend><bdo id='YvxtS'><pre id='YvxtS'><center id='YvxtS'></center></pre></bdo></b><th id='YvxtS'></th></span></q></dt></tr></i><div id='YvxtS'><tfoot id='YvxtS'></tfoot><dl id='YvxtS'><fieldset id='YvxtS'></fieldset></dl></div>

              1. <tfoot id='YvxtS'></tfoot>
              2. <legend id='YvxtS'><style id='YvxtS'><dir id='YvxtS'><q id='YvxtS'></q></dir></style></legend>
                  <bdo id='YvxtS'></bdo><ul id='YvxtS'></ul>

                  本文介绍了如何在 Oracle 中定义触发器 ON COMMIT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  oracle 数据库中是否有任何方法可以定义触发器,如果指定的表发生更改,该触发器将在 COMMIT 之前同步触发(如果抛出异常,则为 ROLLBACK)?

                  Is there any way in oracle database to define trigger which will be fired synchronously before COMMIT (and ROLLBACK if it throws exception) in case when specified table is changed?

                  推荐答案

                  Oracle 中没有 ON COMMIT 触发机制.但是有一些解决方法:

                  There is no ON COMMIT trigger mechanism in Oracle. There are workarounds however:

                  1. 您可以使用带有 ON COMMIT REFRESH 的物化视图并向该 MV 添加触发器.这将允许您在提交时修改基表时触发逻辑.如果触发器引发错误,事务将回滚(您将丢失所有未提交的更改).

                  1. You could use a materialized view with ON COMMIT REFRESH and add triggers to this MV. This would allow you to trigger the logic when a base table has been modified at the time of commit. If the trigger raises an error, the transaction will be rolled back (you will lose all uncommited changes).

                  您可以使用 DBMS_JOB 将操作推迟到提交之后.这将是一个异步操作,并且在某些情况下可能是可取的(例如,当您想在交易成功后发送电子邮件时).如果回滚主事务,作业将被取消.作业和主会话是独立的:如果作业失败,主事务将不会回滚.

                  You can use DBMS_JOB to defer an action to after the commit. This would be an asynchronous action and may be desirable in some cases (for example when you want to send an email after the transaction has been successful). If you roll back the primary transaction, the job will be cancelled. The job and the primary session are independent: if the job fails the main transaction will not be rolled back.

                  就您而言,您可能可以使用选项 (1).我个人不喜欢在触发器中编写业务逻辑,因为它增加了很多复杂性,但从技术上讲,我认为这是可行的.

                  In your case, you could probably use option (1). I personnaly don't like to code business logic in triggers since it adds a lot of complexity but technically I think it would be doable.

                  这篇关于如何在 Oracle 中定义触发器 ON COMMIT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                  • <bdo id='0g14A'></bdo><ul id='0g14A'></ul>

                          <small id='0g14A'></small><noframes id='0g14A'>

                        • <i id='0g14A'><tr id='0g14A'><dt id='0g14A'><q id='0g14A'><span id='0g14A'><b id='0g14A'><form id='0g14A'><ins id='0g14A'></ins><ul id='0g14A'></ul><sub id='0g14A'></sub></form><legend id='0g14A'></legend><bdo id='0g14A'><pre id='0g14A'><center id='0g14A'></center></pre></bdo></b><th id='0g14A'></th></span></q></dt></tr></i><div id='0g14A'><tfoot id='0g14A'></tfoot><dl id='0g14A'><fieldset id='0g14A'></fieldset></dl></div>
                          <tfoot id='0g14A'></tfoot>

                          1. <legend id='0g14A'><style id='0g14A'><dir id='0g14A'><q id='0g14A'></q></dir></style></legend>
                              <tbody id='0g14A'></tbody>