USP_STEP_DELETE

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

                        --check deletion rules, if any


                        declare @COMPLETED bit;
                        declare @INTERACTIONTYPECODEID uniqueidentifier;
                        select @COMPLETED = COMPLETED, @INTERACTIONTYPECODEID=INTERACTIONTYPECODEID from dbo.INTERACTION where ID=@ID;

                        if (@COMPLETED = 1 and @INTERACTIONTYPECODEID is not null) begin
                            update dbo.INTERACTION set 
                                PROSPECTPLANID = null,
                                PLANOUTLINESTEPID = null,
                                PROSPECTPLANSTATUSCODEID = null,
                                CHANGEDBYID = @CHANGEAGENTID,
                                DATECHANGED = getdate()
                            where
                                ID = @ID;
                        end else begin
                            exec USP_INTERACTION_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                        end

                        return 0;
                    end