【问题标题】:Get the operation type inside a "Insert or Update" trigger获取“插入或更新”触发器中的操作类型
【发布时间】:2014-04-26 19:06:04
【问题描述】:

我们能否在 Insert or Update 触发器中捕获该触发器由于 Insert 或由于 Update 语句而被执行?

了解这一点的一种方法是为InsertUpdate 分别触发

但如果我能在一个触发器内完成此操作,那就太好了。

【问题讨论】:

    标签: database oracle plsql triggers oracle11g


    【解决方案1】:

    您可以在触发器内部使用Conditional PredicatesINSERTING/UPDATING/DELETING 来确定 哪个 DML 触发了触发器。

    示例触发器:

    create trigger sample_trigger
        before insert or update
        on sample_table
        for each row
    begin
        case
            when inserting then
                --do something
            when updating then
                --do something
        end case;
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多