USP_BATCHREVENUEBATCHSYSTEMMESSAGES_DELETEBYBATCHID

Parameters

Parameter Parameter Type Mode Description
@BATCHID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN
@DELETESAVE bit IN
@DELETEVALIDATION bit IN
@DELETEIMPORT bit IN
@DELETEDUPLICATERECORDERRORS bit IN
@DELETEADDRESSVALIDATION bit IN

Definition

Copy
/*
Generated by Blackbaud AppFx Platform
Date:  2/6/2025 2:52:20 AM
Assembly Version:  Blackbaud.AppFx.Platform.SqlClr, Version=4.0.3901.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE PROCEDURE dbo.USP_BATCHREVENUEBATCHSYSTEMMESSAGES_DELETEBYBATCHID
(
@BATCHID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier,
@DELETESAVE bit = 1,
@DELETEVALIDATION bit = 1,
@DELETEIMPORT bit = 1,
@DELETEDUPLICATERECORDERRORS bit = 0,
@DELETEADDRESSVALIDATION bit = 1
)

as

set nocount on;    

    declare @contextCache varbinary(128);

    if @CHANGEAGENTID is null
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

    set @contextCache = CONTEXT_INFO();

    set CONTEXT_INFO @CHANGEAGENTID;

    delete from dbo.BATCHREVENUEBATCHSYSTEMMESSAGES 
    where exists (
        select BATCHREVENUE.ID from dbo.BATCHREVENUE where BATCHREVENUE.ID = BATCHREVENUEBATCHSYSTEMMESSAGES.BATCHREVENUEID and BATCHID = @BATCHID
    )
    and (@DELETESAVE = 1 or not ORIGINCODE = 1)
    and (@DELETEVALIDATION = 1 or not ORIGINCODE = 2)
    and (@DELETEIMPORT = 1 or not ORIGINCODE = 3)
    and (@DELETEDUPLICATERECORDERRORS = 1 or not MESSAGETYPECODE = 1) -- MESSAGETYPECODE 1 is a duplicate error

    and (@DELETEADDRESSVALIDATION = 1 or not MESSAGETYPECODE = 2);

    if not @contextCache is null
        set CONTEXT_INFO @contextCache;

    return 0;