USP_CAMPAIGNSUBPRIORITY_DELETE

Executes the "Campaign Category: 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_CAMPAIGNSUBPRIORITY_DELETE (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    ) as begin
                        set nocount on;


                        if exists (select 1 from dbo.REVENUESPLITCAMPAIGN where CAMPAIGNSUBPRIORITYID = @ID)
                        begin
                            raiserror('This campaign subpriority is associated with a revenue record and cannot be deleted.', 13, 1)
                            return 0;
                        end

                        if exists (select 1 from dbo.DESIGNATIONCAMPAIGN where CAMPAIGNSUBPRIORITYID = @ID)
                        begin
                            raiserror('This campaign subpriority is associated with a designation and cannot be deleted.', 13, 1)
                            return 0;
                        end

                        if exists (select 1 from dbo.PLANNEDGIFTDESIGNATIONCAMPAIGN where CAMPAIGNSUBPRIORITYID = @ID)
                        begin
                            raiserror('This campaign subpriority is associated with a planned gift designation and cannot be deleted.', 13, 1)
                            return 0;
                        end

                        if exists (select 1 from dbo.OPPORTUNITYDESIGNATIONCAMPAIGN where CAMPAIGNSUBPRIORITYID = @ID)
                        begin
                            raiserror('This campaign subpriority is associated with an opportunity designation and cannot be deleted.', 13, 1)
                            return 0;
                        end

                        exec dbo.USP_CAMPAIGNSUBPRIORITY_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                    end