USP_RECORDOPERATION_SPONSORSHIPOPPORTUNITYMAKEELIGIBLE

Executes the "Sponsorship Opportunity: Mark Eligible" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being updated.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the update.

Definition

Copy


create procedure dbo.USP_RECORDOPERATION_SPONSORSHIPOPPORTUNITYMAKEELIGIBLE
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier
)
as begin
    set nocount on;

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

    if @CHANGEAGENTID is null  
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
begin try
    update 
     dbo.SPONSORSHIPOPPORTUNITY
    set 
     ELIGIBILITYCODE = 1,
     SPONSORSHIPREASONID = NULL,
       CHANGEDBYID = @CHANGEAGENTID,
         DATECHANGED = @CURRENTDATE
    where 
     ID=@ID;

  if exists(select ID from dbo.SPONSORSHIPOPPORTUNITYPROJECT where ID=@ID)
  begin
    update
      dbo.SPONSORSHIPOPPORTUNITYPROJECT
    set
      STARTDATE = isnull(STARTDATE,dbo.UFN_DATE_GETEARLIESTTIME(@CURRENTDATE)),
      ENDDATE = null,
       CHANGEDBYID = @CHANGEAGENTID,
         DATECHANGED = @CURRENTDATE
    where ID = @ID
  end
end try
begin catch
    exec dbo.USP_RAISE_ERROR;
    return 1;
end catch

    return 0;
end