UFN_CONSTITUENT_ISALUMNUS

Validates whether the constituent record is an alumni.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@CONSTITUENTID uniqueidentifier IN

Definition

Copy


            CREATE function dbo.UFN_CONSTITUENT_ISALUMNUS
            (
                @CONSTITUENTID uniqueidentifier
            ) 
            returns bit
            with execute as caller
            as begin
                    /* A constituent is a student if they have an educational history record with an alumni status */
                if (exists (select EDUCATIONALHISTORY.ID 
                    from dbo.EDUCATIONALHISTORY 
                      inner join dbo.EDUCATIONALINSTITUTION
                        on EDUCATIONALHISTORY.EDUCATIONALINSTITUTIONID = EDUCATIONALINSTITUTION.ID
                      inner join EDUCATIONALHISTORYSTATUS
                        on EDUCATIONALHISTORY.EDUCATIONALHISTORYSTATUSID = EDUCATIONALHISTORYSTATUS.ID
                    where (EDUCATIONALINSTITUTION.ISAFFILIATED = 1) and
                          (EDUCATIONALHISTORYSTATUS.CONSTITUENCYIMPLIEDCODE = 1) and
                          (EDUCATIONALHISTORY.CONSTITUENTID = @CONSTITUENTID)))
        begin
          return 1;
        end

        return 0;
            end