aapf.absence_plan_id,
aapft.name absence_plan_name,
aatft.name absence_type_name,
aatft.absence_type_id,
aatp.ABSENCE_TYPE_PLAN_ID,
aatf.status
FROM
anc_absence_plans_f_tl aapft,
anc_absence_plans_f aapf,
ANC_ABSENCE_TYPES_F_TL aatft,
ANC_ABSENCE_TYPES_F aatf,
ANC_ABSENCE_TYPE_PLANS_F aatp
WHERE 1=1
--------
and aapft.absence_plan_id = aapf.absence_plan_id
AND aapf.plan_status = 'A' -- added to pick only Active Absence Plans
AND aapft.language = 'US'
and aapf.LEGISLATIVE_DATA_GROUP_ID = :P_LDG
--------
and aatft.absence_type_id = aatf.absence_type_id
AND aatf.status = 'A' -- added to pick only Active Absence Plans
AND aatft.language = 'US'
and aatf.LEGISLATIVE_DATA_GROUP_ID = :P_LDG
--------
and aatp.ABSENCE_PLAN_ID = aapf.absence_plan_id
and aatp.ABSENCE_TYPE_ID = aatf.ABSENCE_TYPE_ID
--------
AND trunc(SYSDATE) BETWEEN aapf.effective_start_date AND aapf.effective_end_date
AND trunc(SYSDATE) BETWEEN aapft.effective_start_date AND aapft.effective_end_date
AND trunc(SYSDATE) BETWEEN aatp.effective_start_date AND aatp.effective_end_date
AND trunc(SYSDATE) BETWEEN aatft.effective_start_date AND aatft.effective_end_date
AND trunc(SYSDATE) BETWEEN aatf.effective_start_date AND aatf.effective_end_date