USP_DATAFORMTEMPLATE_VIEW_STUDENTRELATIONCONSTITUENCYCRITERIA

The load procedure used by the view dataform template "Student Relation Constituency Criteria View Data Form"

Parameters

Parameter Parameter Type Mode Description
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@RELATIONSHIPTYPES nvarchar(max) INOUT Person is a constituent when they have one of the following relationships with a student

Definition

Copy


                CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_STUDENTRELATIONCONSTITUENCYCRITERIA
                (
                    @DATALOADED bit = 0 output,
                    @RELATIONSHIPTYPES nvarchar(max) = null output
                )
                as
                    set nocount on;

                    -- be sure to set this, in case the select returns no rows

                    set @DATALOADED = 0;

                    -- populate the output parameters, which correspond to fields on the form.  Note that

                    -- we set @DATALOADED = 1 to indicate that the load was successful.  Otherwise, the system

                    -- will display a "no data loaded" message.

                    if (not exists (select ID from dbo.STUDENTRELATIONCONSTITUENCYSETTINGS))
                    begin
                        set @DATALOADED = 1;
                    end
                    else
                    begin
                        select @DATALOADED = 1,
                               @RELATIONSHIPTYPES = (Case when (Select count(ID) from STUDENTRELATIONCONSTITUENCYTYPES) > 0 then (dbo.UDA_BUILDLIST(Distinct RELATIONSHIPTYPECODE.DESCRIPTION)) else '<none>' end)
                        from dbo.STUDENTRELATIONCONSTITUENCYSETTINGS 
                        left join STUDENTRELATIONCONSTITUENCYTYPES on STUDENTRELATIONCONSTITUENCYSETTINGS.ID = STUDENTRELATIONCONSTITUENCYTYPES.STUDENTRELATIONCONSTITUENCYSETTINGSID
                        left join dbo.RELATIONSHIPTYPECODE ON STUDENTRELATIONCONSTITUENCYTYPES.RELATIONSHIPTYPECODEID = RELATIONSHIPTYPECODE.ID
                        Group by ISCONSTITUENTAFTERGRADUATE
                    end

                    return 0;