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 triggers - can you detect columns not being updated?

Re: Update triggers - can you detect columns not being updated?

From: Mark Styles <lambic_at_msn.com>
Date: 1997/01/07
Message-ID: <32D2F1BC.B86@msn.com>#1/1

John Mara wrote:
>We are building an application that maintains tables,
>with each table containing two audit columns. One column
>contains a user id, another contains the date of the update.
>
>We would like the application to supply these values,
>and have the trigger supply them if the tables are updated
>outside of the application. To do that, we need to detect
>if these two columns are included within an update statement.

You can test if a column is included in the update statement by using the special 'if updating' clause, something like:

if updating ('USER_ID') then

    use application passed id
else

    get trigger to populate user_id;
end if;

This may fail if the update statement is updating the column, but not actually changing the value, e.g updating from 'FRED' to 'FRED'. This can be avoided by doing something like:

if :NEW.USER_ID != :OLD.USER_ID then

    use application passed id
else

    get trigger to populate user_id;
end if;

Hope this helps! Received on Tue Jan 07 1997 - 00:00:00 CST

Original text of this message

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