Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Update Trigger - Mutating Table Problem

Re: Update Trigger - Mutating Table Problem

From: Ivan \(News\) <ivan_val_at_hotmail.com>
Date: 2000/05/02
Message-ID: <8em60h$282a$1@stargate1.inet.it>#1/1

Simply use a BEFORE trigger:

CREATE OR REPLACE TRIGGER customer_upd
BEFORE UPDATE of name,address,city,state,zip ON customer REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
  :NEW.last_updated = sysdate;
END; This forces the current date and time before the row's update.

Ivan

<berj_kacherian_at_hotmail.com> ha scritto nel messaggio news: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.
Received on Tue May 02 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US