USP_REGISTRATIONPACKAGE_DELETE

Executes the "Registration Package: 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_REGISTRATIONPACKAGE_DELETE
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as begin

                        declare @CURRENTDATE datetime;
                        set @CURRENTDATE = getdate();

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

                        --check deletion rules, if any


                        begin try
                            declare @contextCache varbinary(128);

                            --cache current context information

                            set @contextCache = CONTEXT_INFO();

                            --set CONTEXT_INFO to @CHANGEAGENTID

                            set CONTEXT_INFO @CHANGEAGENTID;

                            --Delete records of which registrants purchasd which packages

                            --Currently we are not displaying the registrant package information anywhere so I see no need to prevent a delete because of it

                            delete from
                                dbo.REGISTRANTPACKAGE
                            where
                                REGISTRATIONPACKAGEID = @ID;

                            -- Clean up the batch registrant registration packages

                            delete from
                                dbo.BATCHREVENUEREGISTRANTPACKAGE
                            where
                                REGISTRATIONPACKAGEID = @ID;

                            --reset CONTEXT_INFO to previous value

                            if not @contextCache is null
                                set CONTEXT_INFO @contextCache;

                            exec USP_REGISTRATIONPACKAGE_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                        end try

                        begin catch
                            exec dbo.USP_RAISE_ERROR;
                            return 1;
                        end catch
                        return 0;
                    end