USP_PLEDGEREMINDERPROCESS_DELETE

Executes the "Pledge Reminder Process: Delete" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being deleted.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the delete.

Definition

Copy


                CREATE procedure dbo.USP_PLEDGEREMINDERPROCESS_DELETE
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as 
                        set nocount on

                        exec dbo.USP_BUSINESSPROCESS_PARAMETERSETCANBEDELETED 'PLEDGEREMINDERPROCESSSTATUS', @ID;

                        -- if records have not been marked sent for any runs of this process, delete the records from the PLEDGEREMINDERSENT table


                        --Cache CONTEXT INFO

                        declare @contextCache varbinary(128);
                        set @contextCache = CONTEXT_INFO();

                        if not @CHANGEAGENTID is null
                            set CONTEXT_INFO @CHANGEAGENTID;

                        delete from dbo.PLEDGEREMINDERSENT where PLEDGEREMINDERSENT.ID in 
                            (select PRS.ID from dbo.PLEDGEREMINDERSENT PRS inner join dbo.PLEDGEREMINDERPROCESSSTATUS STATUS on PRS.PLEDGEREMINDERPROCESSSTATUSID = STATUS.ID
                            where STATUS.PARAMETERSETID = @ID and PRS.SENTDATE is null);

                        --Restore CONTEXT_INFO

                        if not @contextCache is null
                            set CONTEXT_INFO @contextCache;

                        exec dbo.USP_BUSINESSPROCESSINSTANCE_DELETE '84414BD2-3196-4697-998A-2493C29A302A', @ID, @CHANGEAGENTID;

                        exec dbo.USP_BUSINESSPROCESSCOMMPREF_DELETE '84414BD2-3196-4697-998A-2493C29A302A', @ID, @CHANGEAGENTID;

                        exec dbo.USP_PLEDGEREMINDERPROCESS_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                        return 0;