Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Solution for mutating table error while using triggers

Priya1111Feb 18 2014 — edited Feb 18 2014

Hi,

Could you please give the solution for the mutating table errore  while using triggers. I will give the simple scenario here,

I am creating a trigger on  employees table, whenever any DML operations takes place in employees table, it should execute the trigger body. I have intentionally used the employees table in the trigger body also. Please provide me the solution.

Trigger:

create or replace trigger test_trigger

before insert or update or delete on employees

for each row

declare

a employees.first_name%type;

begin

select first_name into  a from employees where job_id ='AD_PRES';

end;

DML statement :

update employees set salary =20000 where job_id='AD_PRES' (I execute this query)

Error message:

ORA-04091: table HR.EMPLOYEES is mutating, trigger/function may not see it

ORA-06512: at "HR.TEST_TRIGGER", line 4

ORA-04088: error during execution of trigger 'HR.TEST_TRIGGER'

Can anyone tell , in what other scenarios, we will get this mutating table error or recursive error?

Thanks in advance

This post has been answered by KarK on Feb 18 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2014
Added on Feb 18 2014
2 comments
829 views