From: The Magnet on
Ok, probably a simple question but, say I have an after update on a
table of maybe 20 columns, for each row.

If a column in the source table is updated I should use the :NEW,
right? And if it is not updated I assume I should use the :OLD?

I guess what I am getting is I do not know which columns are updated,
so, how do I code the trigger to know which to use, :NEW or :OLD,
since not all columns will be updated?

From: Mark D Powell on
On Jul 8, 2:49 pm, The Magnet <a...(a)unsu.com> wrote:
> Ok, probably a simple question but, say I have an after update on a
> table of maybe 20 columns, for each row.
>
> If a column in the source table is updated I should use the :NEW,
> right?  And if it is not updated I assume I should use the :OLD?
>
> I guess what I am getting is I do not know which columns are updated,
> so, how do I code the trigger to know which to use, :NEW or :OLD,
> since not all columns will be updated?

If you use the :old or :new tags depends on what you are trying to
accomplish.

If you want to know if a specific column value changed you can

If :old.column_a <> :new.column_a
then change_logic
else no_change_logic
end if;

Often you just refer to the :old columns to build a history/audit row
or refer to the :new columns to be used in updating a related table.

HTH -- Mark D Powell --