![]() |
---|
/* Generated by Blackbaud AppFx Platform Date: 8/5/2009 1:24:56 PM Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=1.0.0.345, Culture=neutral, PublicKeyToken=null Copyright Blackbaud */ CREATE TRIGGER dbo.TR_VENDOR1099SETTING_AUDIT_DELETE ON dbo.VENDOR1099SETTING AFTER DELETE NOT FOR REPLICATION AS declare @ChangeAgentID uniqueidentifier declare @AuditKey uniqueidentifier declare @AuditDate datetime set nocount on --peform the audit if dbo.UFN_AUDITENABLED('VENDOR1099SETTING') = 1 begin -- the audit key is used to associate the rows in the audit table with a single atomic deletion/modification -- for a delete, set @AuditKey = NewID() set @AuditDate = GetDate() --Get the change agent from the CONTEXT_INFO. If an application wishes to mark a row as deleted by a non-default changeagent then it will have to update the auditrow after the delete using the ID field (where AUDITTYPECODE=2) exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENTFROMCONTEXT @ChangeAgentID output INSERT INTO dbo.VENDOR1099SETTINGAUDIT( AUDITRECORDID, AUDITKEY, AUDITCHANGEAGENTID, AUDITDATE, AUDITTYPECODE, [CHECK1099BOX9], [CHECK10992TIN], [NAMEFIRSTLINEALIASTYPECODEID], [NAMESECONDLINEALIASTYPECODEID], [ADDRESSID], [ADDEDBYID], [CHANGEDBYID], [DATEADDED], [DATECHANGED] ) SELECT ID, @AuditKey, @ChangeAgentID, @AuditDate, 2, --Before DELETE [CHECK1099BOX9], [CHECK10992TIN], [NAMEFIRSTLINEALIASTYPECODEID], [NAMESECONDLINEALIASTYPECODEID], [ADDRESSID], [ADDEDBYID], [CHANGEDBYID], [DATEADDED], [DATECHANGED] FROM DELETED end |