UFN_PROSPECTPLANMANAGERHISTORY_VALIDSECONDARYMANAGERENDDATE

Validates that the end date of the historical prospect plan secondary manager is after the start and end date of the current prospect plan secondary manager.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@PROSPECTPLANID uniqueidentifier IN
@DATETO datetime IN

Definition

Copy


            CREATE function dbo.UFN_PROSPECTPLANMANAGERHISTORY_VALIDSECONDARYMANAGERENDDATE
            (
                @PROSPECTPLANID uniqueidentifier,
                @DATETO datetime
            )
            returns bit
            with execute as caller
            as begin
                if exists (
                    select top 1
                        ID
                    from
                        dbo.PROSPECTPLAN
                    where
                        ID = @PROSPECTPLANID and
                        (
                            (
                                (SECONDARYMANAGERSTARTDATE is not null) and
                                (SECONDARYMANAGERSTARTDATE < @DATETO)
                            ) or
                            (
                                (SECONDARYMANAGERENDDATE is not null) and
                                (SECONDARYMANAGERENDDATE < @DATETO)
                            )
                        )
                    )
                    return 0;

                return 1;

            end