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

    1. <tfoot id='QBuHd'></tfoot>

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

    2. <legend id='QBuHd'><style id='QBuHd'><dir id='QBuHd'><q id='QBuHd'></q></dir></style></legend>
      • <bdo id='QBuHd'></bdo><ul id='QBuHd'></ul>

      Oracle:排除用于触发触发器的一列的更新

      Oracle: excluding updates of one column for firing a trigger(Oracle:排除用于触发触发器的一列的更新)

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

              <tbody id='5rYZO'></tbody>
              <bdo id='5rYZO'></bdo><ul id='5rYZO'></ul>
              1. <small id='5rYZO'></small><noframes id='5rYZO'>

              2. 本文介绍了Oracle:排除用于触发触发器的一列的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 oracle 中,我可以指定列,这应该会引发触发器的触发:

                In oracle I can specify the columns, which should induce a firing of a trigger:

                create or replace trigger my_trigger
                before update of col1, col2, col3 on my_table for each row
                begin
                  // the trigger code will be executed only if col1 or col2 or col3 was updated
                end;
                

                现在我想执行以下操作:当仅更新一列时,我不希望触发触发器.这怎么可能?

                Now I want to do the following: I don't want the trigger to fire, when only one column was updated. How is this possible?

                我可以列出除列之外的所有列,这些列不应导致触发触发器.这对于有很多列的表来说相当麻烦.

                I could list all columns except the one, which should not induce a firing of the trigger. This is quite cumbersome for tables with many columns.

                另一种方法是像这样使用 UPDATING 函数:

                Another way would be to use the UPDATING function like this:

                if not updating('COL3') then ...
                

                但是如果我同时更改 COL1 COL3,则该语句的计算结果为 false.这不是我想要的,因为我想在 只有一个 列 (COL3) 更新时限制执行.

                But if I changed COL1 and COL3 at once, the statement evaluates to false. That's not what I want since, I want to restrict the execution when only one column (COL3) was updated.

                推荐答案

                你可以这样做:

                create or replace trigger my_trigger
                before update on my_table
                for each row
                declare
                   n_cols integer := 0;
                begin
                   for r in (select column_name from all_tab_columns
                             where table_name = 'MY_TABLE'
                             and owner = 'MY_SCHEMA')
                   loop
                      if updating(r.column_name) then
                         n_cols := n_cols + 1;
                         exit when n_cols > 1;
                      end if;
                   end loop;
                   if n_cols > 1 then
                      do_something;
                   end if;
                end;
                

                虽然效率可能不是很高!

                Probably not terribly efficient though!

                这篇关于Oracle:排除用于触发触发器的一列的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                How do I split flat file data and load into parent-child tables in database?(如何拆分平面文件数据并加载到数据库中的父子表中?)
                How to import CSV into sqlite using RSqlite?(如何使用 RSqlite 将 CSV 导入 sqlite?)
                Import CSV to Update rows in table(导入 CSV 以更新表中的行)
                Importing MaxMind#39;s GeoLite2 to MySQL(将 MaxMind 的 GeoLite2 导入 MySQL)
                Import / Export database with SQL Server Server Management Studio(使用 SQL Server Server Management Studio 导入/导出数据库)
                How do you import a large MS SQL .sql file?(如何导入大型 MS SQL .sql 文件?)

                <legend id='DDuuh'><style id='DDuuh'><dir id='DDuuh'><q id='DDuuh'></q></dir></style></legend>

                    <tbody id='DDuuh'></tbody>

                      • <small id='DDuuh'></small><noframes id='DDuuh'>

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