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!

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

299008Jul 26 2005 — edited Jul 27 2005
Hi,

I keep getting this error message for my trigger when performing an
insert..select statement (standard plain old insert works):

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

The trigger is as follows:

CREATE OR REPLACE TRIGGER MYTABLE_BEF_INS_CHECK
BEFORE INSERT ON MYTABLE
DECLARE
v_o_id number(10);
BEGIN
IF :new.TYP = 'O' THEN
SELECT 1
INTO v_o_id
FROM MYTABLE WHERE TYP = 'O' AND ID=:new.ID;
END IF;
END;

The thing is the trigger works fine for a standard insert like:

insert into MYTABLE( id,typ)
values(426672,'O')

No problem the above works. But when I try an insert select..it
fails.

insert into MYTABLE( id,typ)
SELECT x_id, 'O' from AnyOtherTable;


the above will fail.

Anyone an idea why this is the case??

thx.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2005
Added on Jul 26 2005
9 comments
537 views