UFN_STEWARDSHIPPLAN_VALIDMANAGERSTARTDATE

Validates that the start date of a stewardship plan's manager is after the end date of its previous managers.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@STEWARDSHIPPLANID uniqueidentifier IN
@MANAGERSTARTDATE date IN

Definition

Copy


            create function dbo.UFN_STEWARDSHIPPLAN_VALIDMANAGERSTARTDATE
            (
                @STEWARDSHIPPLANID uniqueidentifier,
                @MANAGERSTARTDATE date
            )
            returns bit
            with execute as caller
            as begin

                if exists (
                    select 1
                    from 
                        dbo.STEWARDSHIPPLANMANAGERHISTORY
                    where 
                        STEWARDSHIPPLANID = @STEWARDSHIPPLANID
                        and (
                            @MANAGERSTARTDATE is null
                            or ENDDATE > @MANAGERSTARTDATE
                        )

                    )
                    return 0;

                return 1;
            end