eval: modeling an [not so] effective date

Posts   
 
    
Dhominator avatar
Dhominator
User
Posts: 16
Joined: 28-Dec-2004
# Posted on: 21-Sep-2006 00:52:58   

Have a table/column that supports scheduling something for a future effective date. So, there can be several rows of which only one is currently in effect. Lame design aside, is there a way to model this relationship in the designer? What strategies might one use to fetch only the row currently in effect?

sproc snippet

FROM dbo.Plan iplan WITH (NOLOCK)
    INNER JOIN dbo.PlanInstance planinstance WITH (NOLOCK)
        ON iplan.InsurancePlanID = planinstance.InsurancePlanID
        INNER JOIN (
                SELECT
                    instance2.InsuranceInstanceID,
                    instance2.ClaimTitle,
                    instance2.Notes,
                    instance2.ClaimType,
                    instance2.SendElectronically,
                    instance2.TrackParticipation,
                    instance2.AllowUsage,
                    instance2.Email,
                    instance2.SwitchImplementationType,
                    instance2.EffectiveDate,
                    instance2.AssignsPin,
                    instance2.AssignsGrp,
                    instance2.IsGovernment,
                    instance2.InsuranceInstanceVersion
                FROM dbo.InsuranceInstance instance2 WITH (NOLOCK)
                    INNER JOIN dbo.PlanInstance planinstance2 WITH (NOLOCK)
                        ON instance2.InsuranceInstanceID = planinstance2.InsuranceInstanceID
                WHERE instance2.EffectiveDate <= GETDATE()
                    AND instance2.EffectiveDate = (
                            SELECT MAX( instance3.EffectiveDate )
                            FROM dbo.InsuranceInstance instance3 WITH (NOLOCK)
                                INNER JOIN dbo.PlanInstance planinstance3 WITH (NOLOCK)
                                    ON instance3.InsuranceInstanceID = planinstance3.InsuranceInstanceID
                            WHERE planinstance3.InsurancePlanID = planinstance2.InsurancePlanID
                                AND instance3.EffectiveDate <= GETDATE()
                        )
            ) instance
            ON planinstance.InsuranceInstanceID = instance.InsuranceInstanceID

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 21-Sep-2006 02:59:53   

I'm not sure of a way to model this in the designer. Are you wanting a property that represents the Effective date or a typed list that returns this data?