TR_GLACCOUNT_AUDIT_DELETE
Definition
Copy
/*
Generated by Blackbaud AppFx Platform
Date: 3/19/2013 1:11:27 AM
Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=3.0.504.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE TRIGGER dbo.TR_GLACCOUNT_AUDIT_DELETE ON dbo.GLACCOUNT 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('GLACCOUNT') = 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.GLACCOUNTAUDIT(
AUDITRECORDID,
AUDITKEY,
AUDITCHANGEAGENTID,
AUDITDATE,
AUDITTYPECODE,
[ACCOUNTNUMBER],
[ACCOUNTDESCRIPTION],
[PDCATEGORYDEFINITIONID],
[ADDEDBYID],
[CHANGEDBYID],
[DATEADDED],
[DATECHANGED],
[PDACCOUNTSYSTEMID],
[LEDGERACCOUNTWORKFLOWSTAGECODEID],
[ACTIVE],
[ACCOUNTSTRING],
[DATAELEMENT1ID],
[DATAELEMENT2ID],
[DATAELEMENT3ID],
[DATAELEMENT4ID],
[DATAELEMENT5ID],
[DATAELEMENT6ID],
[DATAELEMENT7ID],
[DATAELEMENT8ID],
[DATAELEMENT9ID],
[DATAELEMENT10ID],
[DATAELEMENT11ID],
[DATAELEMENT12ID],
[DATAELEMENT13ID],
[DATAELEMENT14ID],
[DATAELEMENT15ID],
[DATAELEMENT16ID],
[DATAELEMENT17ID],
[DATAELEMENT18ID],
[DATAELEMENT19ID],
[DATAELEMENT20ID],
[DATAELEMENT21ID],
[DATAELEMENT22ID],
[DATAELEMENT23ID],
[DATAELEMENT24ID],
[DATAELEMENT25ID],
[DATAELEMENT26ID],
[DATAELEMENT27ID],
[DATAELEMENT28ID],
[DATAELEMENT29ID],
[DATAELEMENT30ID],
[ACCOUNTALIAS],
[HASHVALUE],
[MD5HASHVALUE]
)
SELECT
ID,
@AuditKey,
@ChangeAgentID,
@AuditDate,
2, --Before DELETE
[ACCOUNTNUMBER],
[ACCOUNTDESCRIPTION],
[PDCATEGORYDEFINITIONID],
[ADDEDBYID],
[CHANGEDBYID],
[DATEADDED],
[DATECHANGED],
[PDACCOUNTSYSTEMID],
[LEDGERACCOUNTWORKFLOWSTAGECODEID],
[ACTIVE],
[ACCOUNTSTRING],
[DATAELEMENT1ID],
[DATAELEMENT2ID],
[DATAELEMENT3ID],
[DATAELEMENT4ID],
[DATAELEMENT5ID],
[DATAELEMENT6ID],
[DATAELEMENT7ID],
[DATAELEMENT8ID],
[DATAELEMENT9ID],
[DATAELEMENT10ID],
[DATAELEMENT11ID],
[DATAELEMENT12ID],
[DATAELEMENT13ID],
[DATAELEMENT14ID],
[DATAELEMENT15ID],
[DATAELEMENT16ID],
[DATAELEMENT17ID],
[DATAELEMENT18ID],
[DATAELEMENT19ID],
[DATAELEMENT20ID],
[DATAELEMENT21ID],
[DATAELEMENT22ID],
[DATAELEMENT23ID],
[DATAELEMENT24ID],
[DATAELEMENT25ID],
[DATAELEMENT26ID],
[DATAELEMENT27ID],
[DATAELEMENT28ID],
[DATAELEMENT29ID],
[DATAELEMENT30ID],
[ACCOUNTALIAS],
[HASHVALUE],
[MD5HASHVALUE]
FROM DELETED
end