[thelist] SQL Variables

Jonathan Cone JCone at municode.com
Thu Jan 23 16:51:01 CST 2003

It may help.  I understand the inserted and deleted tables.  From what I know you're right on the mark.  Maybe our problem was we were trying to pick and choose what was coming out of those tables and into our audit table.  I think you're saying to dump everything from those tables regardless of if we need it or not and  then sort it out later?

-----Original Message-----
From: rudy [mailto:r937 at interlog.com]
Sent: Thursday, January 23, 2003 5:44 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] SQL Variables

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

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?


* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !

More information about the thelist mailing list