Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: What is Wrong with this Trigger?
On Tue, 9 Feb 1999 15:41:47 -0600, "John Jennings" <jjennings_at_hertz.com> wrote:
>I have a trigger that is supposed to stamp a date. Here is a layout of my
>table.
>
>Problem_Code varchar(15)
>Date_Resolved Date
>
>Trigger Text:
>
>CREATE OR REPLACE TRIGGER "EXAV"."UPD_PCODE_RESOLVED"
>BEFORE INSERT OR UPDATE OF "PROBLEM_CODE" ON "EXAV"."PROBLEMS"
>REFERENCING OLD AS OLD NEW AS NEW
>FOR EACH ROW
>WHEN (NEW.PROBLEM_CODE='RESOLVED')
>BEGIN
>UPDATE PROBLEMS SET DATE_RESOLVED=SYSDATE;
>END;
>
>Here is the error message when 'Problem_Code' = 'RESOLVED':
>
>"Table Problems is mutating, trigger/function may not see it. ORA-06512: at
>"EXAV.UPD_PCODE_RESOLVED", line 2
>ORA-04088: error during execution of trigger 'EXAV.UPD_PCODE_RESOLVED'
>(#4091).
>
You can't issue an update on the table that the trigger is attached to. That is what is causing the mutating trigger. Instead of update table, all you need to do is this...
:new.date_resolved := sysdate;
which says to set the new value of the date_resolved column to sysdate.
hope this helps.
chris.
>Any assistance is appreciated.
>
>JJ
>
>
>
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.