UFN_SPROPPCHILD_VALID_HIVPOSITIVECODE_FOR_GROUP

Validates that the child sponsorship opportunity has the same HIVPOSITIVECODE value as the sponsorship group.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@HIVPOSITIVE tinyint IN

Definition

Copy


            create function dbo.UFN_SPROPPCHILD_VALID_HIVPOSITIVECODE_FOR_GROUP
            (
                @ID uniqueidentifier,
                @HIVPOSITIVE tinyint
            )
              returns bit
              with execute as caller
              as begin
          declare @HIVVAL tinyint;

          select 
            @HIVVAL = SG.ISHIVPOSITIVECODE
          from
            SPONSORSHIPOPPORTUNITY SO
            inner join SPONSORSHIPOPPORTUNITYGROUP SG on SO.SPONSORSHIPOPPORTUNITYGROUPID = SG.ID
          where
            SO.ID = @ID;

          /* 0 = Any on group or child hivpositive = group hivpositive or both is null.*/
          if @HIVVAL = 0 or (@HIVPOSITIVE = @HIVVAL) or (@HIVPOSITIVE = 0 and @HIVVAL = 2)
                    return 1;

                return 0;
            end