Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Update Trigger - Mutating Table Problem
<berj_kacherian_at_hotmail.com> schreef in berichtnieuws
8ed4e4$vog$1_at_nnrp1.deja.com...
> Here is the problem in one statement, I am getting ORA-04091.
>
> Here is what I am trying to accomplish: We would like to track when
> the last time was that a customer updated their info. The customer
> table has a LAST_UPDATED field in it. During inserts we can set a
> default value for it. But the default value does not work during
> updates. So each time a row in the customer table is updated I have a
> trigger trying to update the LAST_UPDATED column. But this results in
> an ORA-04091. I guess because they are both accessing the same table.
>
> Here is what the trigger looks like:
>
> create trigger customer_upd after update of name,address,city,state,zip
> on customer for each row
> begin update customer set last_updated=sysdate where id=:new.id;
> end;
>
> Is there another way to do this?
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Yes
The correct code is
create trigger customer_upd after update of name,address,city,state,zip
on customer for each row
begin
:new.last_updated:=sysdate;
end;
/
Hth ,
Sybrand Bakker, Oracle DBA Received on Sat Apr 29 2000 - 00:00:00 CDT