【问题标题】:Oracle trigger muating errorOracle 触发器突变错误
【发布时间】:2017-06-10 04:21:16
【问题描述】:
CREATE OR REPLACE TRIGGER Testtriger
    after insert ON table2 referencing new as new old as old
    for each row
declare 
    flagtemp varchar2(1);
begin
    select flag into flagtemp from table2 where docid = :new.docid;
    --if :new.cardtypeflag = 'T' then
    update table1 set col1 = 'F' , col2= 'T', inactive = 'T', col3 = 'T' 
    where    tabid = :new.docid;
    --end if;
end;
/

此触发器出现变异错误,请帮助修复它。

【问题讨论】:

标签: oracle triggers mutating-table


【解决方案1】:

您的触发器包含针对具有触发器的表执行的选择:

select flag into flagtemp from table2 where docid = :new.docid;

Oracle 数据库操作需要可预测的状态。此选择的结果是不可预测的,因为您处于事务中间:尚未应用数据。因此触发器因突变错误而失败。

在这种情况下,您似乎需要做的就是

flagtemp := :new.flag;

或者,更好的是,取消赋值,因为您不在触发器的其余部分使用局部变量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-18
    • 1970-01-01
    • 2021-09-20
    • 2013-02-06
    • 1970-01-01
    • 2018-11-30
    • 1970-01-01
    • 2012-09-18
    相关资源
    最近更新 更多