首页 > 解决方案 > 运行触发器时出现变异错误

问题描述

当我尝试更新表时,我收到表正在变异错误

update flight 
set captainStaffID='S0009' 
where flightid='000000043';

这是触发器:

create or replace trigger trigger1 
before INSERT OR UPDATE of captainStaffID,firstOfficerStaffID on flight
for each row


if UPDATING  then
    select count(*) into temp7 
    from flight 
    where flightid in (select ap.flightid  
                       from ADDITIONAL_PILOT ap 
                       where activityCode ='TR');
    dbms_output.put_line('New'||:new.flightid||'OLD'||:old.flightid);


end if;

end trigger1;
/

第 1 行的错误:

ORA-04091: 表 XXXXXX.FLIGHT 正在变异,触发器/函数可能看不到它
ORA-06512: 在“XXXXXX.TRIGGER1”,第 7 行
ORA-04088: 执行触发器时出错.....TRIGGER1'

我正在使用以下更新查询来启动我的触发器

update flight set captainStaffID='S0009' where flightid='000000043';

标签: sqloracledatabase-triggermutating-table

解决方案


推荐阅读