USP_SPONSORSHIPOPPORTUNITYRESERVE_UPDATESTATUS

Refresh the status of a sponsorship opportunity reservation key.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN

Definition

Copy


CREATE procedure dbo.USP_SPONSORSHIPOPPORTUNITYRESERVE_UPDATESTATUS (
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier
)
as
begin
    if @CHANGEAGENTID is null
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

    declare @COUNT int;

    select @COUNT = count(*)
    from dbo.SPONSORSHIPOPPORTUNITY
    where RESERVATIONKEYID = @ID;

    update dbo.SPONSORSHIPOPPORTUNITYRESERVATIONSTATUS
    set STATUSCODE = case @COUNT when 0 then 0 else 1 end,
        CHANGEDBYID = @CHANGEAGENTID,
        DATECHANGED = getdate()
    where OPPORTUNITYRESERVATIONKEYID = @ID
    and STATUSCODE <> case @COUNT when 0 then 0 else 1 end;
end