I created a before delete trigger:
create or replace trigger myTrigger3
before delete on emp
for each row
begin
update emp set mgr = 'Null' where mgr = :old.emp_name;
end;
Where table is
emp(emp_id integer primary key, emp_name varchar(20), mgr varchar(20))
But when I run this statement the trigger is not running.
delete from emp where emp_id = 1004;
select * from emp;
Error report -
ORA-04091: table DB20178004.EMP is mutating, trigger/function may not see it
ORA-06512: at "DB20178004.MYTRIGGER3", line 2
ORA-04088: error during execution of trigger 'DB20178004.MYTRIGGER3'
for each row, where you update all managers no longer found in the table. Another is to use a compound trigger, where you remember all deleted IDs in theafter each rowsection and use them in theafter statementsection for the updates. - Thorsten Kettnerset mgr = 'Null'should probably beset mgr = null. You don't really want to set mgr to a string containing the word 'Null', do you? - Thorsten Kettner