USP_PROGRAMDOCUMENT_DELETE

Executes the "Program Document 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_PROGRAMDOCUMENT_DELETE
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier
)
as begin

    --get the priority

    declare @SEQUENCE integer;
    declare @PROGRAMID uniqueidentifier;

    select
        @SEQUENCE = SEQUENCE,
        @PROGRAMID = PROGRAMID
    from dbo.PROGRAMDOCUMENT
    where ID = @ID;

    exec USP_PROGRAMDOCUMENT_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID

    update dbo.PROGRAMDOCUMENT
    set 
        SEQUENCE = SEQUENCE - 1,
        CHANGEDBYID = @CHANGEAGENTID,
        DATECHANGED = getdate()
    where
        SEQUENCE > @SEQUENCE and
        PROGRAMID = @PROGRAMID

    return 0;

end