Getting Mutating error while running trigger

50 Views Asked by At

I am getting table is mutating error when I try to update the table

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

Here is the trigger:

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

ERROR at line 1:

ORA-04091: table XXXXXx.FLIGHT is mutating, trigger/function may not see it
ORA-06512: at "XXXXXX.TRIGGER1", line 7
ORA-04088: error during execution of trigger .....TRIGGER1'

I am using below update query to initiate my trigger

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

There are 0 best solutions below