[thelist] SQL Variables

rudy r937 at interlog.com
Thu Jan 23 16:44:01 CST 2003


my understanding is that a trigger is defined on the table on one or more of
only three table actions -- delete, insert, update -- and not on individual
columns

during execution of the trigger, the trigger code has access to two special
tables called "deleted" and "inserted" which have the same structure as the
table that the trigger is defined on

for example, when you delete one or more rows, the "deleted" table contains
the deleted row(s), and the "inserted" table is empty

for an update trigger, the "deleted" table contains the rows before the
update, and the "inserted" table contains the rows after the update

if you want to know exactly which field was changed, your trigger code would
have to compare the before and after values of each column

most triggers, in an audit scenario, copy entire rows from either or both
the "deleted" and "inserted" tables to the audit table

does that help?


rudy




More information about the thelist mailing list