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

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

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                <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>