UFN_SPONSORSHIP_VALIDOPPORTUNITYFORFINANCIALSPONSOR

Returns 0 if the opportunity is not valid for sponsoring by the specified financial sponsor.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@SPONSORSHIPOPPORTUNITYID uniqueidentifier IN
@FINANCIALSPONSORID uniqueidentifier IN
@IGNORESPONSORSHIPID uniqueidentifier IN

Definition

Copy


create function dbo.UFN_SPONSORSHIP_VALIDOPPORTUNITYFORFINANCIALSPONSOR(
    @SPONSORSHIPOPPORTUNITYID uniqueidentifier,
    @FINANCIALSPONSORID uniqueidentifier,
    @IGNORESPONSORSHIPID uniqueidentifier
)
returns bit
with execute as caller
as begin
    if (select UNIQUEOPPORTUNITIESFORGIFTDONOR
        from dbo.SPONSOR
        where ID = @FINANCIALSPONSORID) = 1
    begin
        if exists(select 'x'
                  from dbo.REVENUE
                  inner join dbo.REVENUESPLIT on REVENUESPLIT.REVENUEID = REVENUE.ID
                  inner join dbo.SPONSORSHIP on SPONSORSHIP.REVENUESPLITID = REVENUESPLIT.ID
                  where REVENUE.CONSTITUENTID = @FINANCIALSPONSORID
                  and SPONSORSHIP.SPONSORSHIPOPPORTUNITYID = @SPONSORSHIPOPPORTUNITYID
                  and SPONSORSHIP.STATUSCODE in(0,1)
                  and SPONSORSHIP.ID <> @IGNORESPONSORSHIPID)
            return 0;
    end

    return 1;
end