Re: TRICKY TRIGGER QUESTION

From: Eric & Carole Kamradt <kamradt_at_inconnect.com>
Date: 1997/08/08
Message-ID: <33EB22E3.31F4F39B_at_inconnect.com>#1/1


sprajapa_at_fmrco.com wrote:

> Using update trigger, is there any way to capture primary key updates
> into a separate table ? I want to capture all primary key updates in
> a table given as:
>
> log_table
> (table_name char(30),
> old_key_val char(255),
> new_key_val char(255)
> )
>
> There may be one or more rows updated in a "single trigger execution
> cycle".
> OBVIOUSLY, Primary key column(s) are updated either for all rows or
> for
> none within THAT trigger execution.
>
> Thanks in advance.
>
> regards,
> Sunil Prajapati
>
> -------------------==== Posted via Deja News
> ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet

try --
CREATE OR REPLACE TRIGGER xxx
BEFORE UPDATE......
FOR EACH ROW
BEGIN   IF :old.PRIMARY_KEY != :new.PRIMARY_KEY     OR (:old.PRIMARY_KEY IS NULL AND :new.PRIMARY_KEY IS NOT NULL)   THEN
      INSERT INTO log_table ............   END IF; END; Good luck

Eric Kamradt
hm: (801) 567-0912
mailto: kamradt_at_inconnect.com
http://www.inconnect.com/~kamradt/resume.html Received on Fri Aug 08 1997 - 00:00:00 CEST

Original text of this message