USP_BENEFIT_DELETE

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

                        if exists (select top 1 ID from dbo.APPEALBENEFITDETAIL where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with appeals and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        if exists (select top 1 ID from dbo.REVENUEBENEFIT where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with revenue and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        if exists (select top 1 ID from dbo.EVENTPRICEBENEFIT where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with events and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        if exists (select top 1 ID from dbo.REGISTRANTBENEFIT where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with events and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        if exists (select top 1 ID from dbo.MEMBERSHIPLEVELBENEFIT where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with membership levels and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        if exists (select top 1 ID from dbo.CONSTITUENTRECOGNITIONBENEFIT where BENEFITID = @ID)
                        begin
                            raiserror('This benefit is associated with a constituent recognition program and cannot be deleted.', 13, 1);
                            return 0;
                        end

                        exec USP_BENEFIT_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
                        return 0;
                    end