0
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;
/

这个触发器给出了变异错误,请帮助修复它。

4

1 回答 1

1

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

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

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

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

flagtemp := :new.flag;

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

于 2017-01-25T07:48:00.490 回答