USP_DATAFORMTEMPLATE_EDIT_SPONSORSHIPREASON

The save procedure used by the edit dataform template "Sponsorship Reason Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@REASON nvarchar(100) IN Reason
@REASONTYPECODE int IN Type
@TRANSFERSPONSORSFORINELIGIBLECHILD bit IN Transfer sponsors for ineligible child

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_SPONSORSHIPREASON (
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier,
    @REASON nvarchar(100),
    @REASONTYPECODE int,
    @TRANSFERSPONSORSFORINELIGIBLECHILD bit
)
as

    set nocount on;

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

    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()

  if @REASONTYPECODE not in (1,2)
    set @TRANSFERSPONSORSFORINELIGIBLECHILD = 0

    begin try
        update dbo.SPONSORSHIPREASON set
            REASON = @REASON,
            REASONTYPECODE = @REASONTYPECODE,
            TRANSFERSPONSORSFORINELIGIBLECHILD = @TRANSFERSPONSORSFORINELIGIBLECHILD
        where ID = @ID
    end try
    begin catch
        exec dbo.USP_RAISE_ERROR
        return 1
    end catch

return 0;