dbTalk Databases Forums  

Triggers

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Triggers in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
The Magnet
 
Posts: n/a

Default Triggers - 07-08-2010 , 01:49 PM






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?

Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: Triggers - 07-08-2010 , 03:06 PM






On Jul 8, 2:49*pm, The Magnet <a... (AT) unsu (DOT) com> wrote:
Quote:
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 ld 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 ld.column_a <> :new.column_a
then change_logic
else no_change_logic
end if;

Often you just refer to the ld 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 --

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.