USP_EVENTGROUP_DELETE

Executes the "Event Group: 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_EVENTGROUP_DELETE
                        (
                            @ID uniqueidentifier,
                            @CHANGEAGENTID uniqueidentifier = null
                        )
                        as
                            declare @contextCache varbinary(128);

                            set nocount on;

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

                            begin try
                            /* cache current context information */
                            set @contextCache = CONTEXT_INFO();

                            /* set CONTEXT_INFO to @CHANGEAGENTID */
                            set CONTEXT_INFO @CHANGEAGENTID;

                            delete from dbo.EVENTGROUPMEMBER where EVENTGROUPID = @ID;

                            /* reset CONTEXT_INFO to previous value */
                            if not @contextCache is null
                                set CONTEXT_INFO @contextCache;

                            exec USP_EVENTGROUP_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
                            end try

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

                            return 0;