SELECT hts.approval_status ,hts.timecard_id, hts.resource_id, hts.start_time,
hts.stop_time, hts.submission_date,
htb1.start_time each_day, hta.attribute1 project_id,
hta.attribute2 task_id,papa.name, papa.segment1, pt.task_number, htb2.measure, pt.task_name
FROM hxc_time_building_blocks htb,
hxc_time_building_blocks htb1,
hxc_time_building_blocks htb2,
hxc_time_attribute_usages htau,
hxc_time_attributes hta,
pa_projects_all papa,
hxc_timecard_summary hts,
pa_tasks pt
WHERE htb1.parent_building_block_id = htb.time_building_block_id
AND htb1.parent_building_block_ovn = htb.object_version_number
AND htb.date_to = hr_general.end_of_time
AND htb.SCOPE = 'TIMECARD'
AND htb1.SCOPE = 'DAY'
--AND htb1.date_to = hr_general.end_of_time
AND htb2.parent_building_block_id = htb1.time_building_block_id
AND htb2.parent_building_block_ovn = htb1.object_version_number
AND htb2.SCOPE = 'DETAIL'
--AND htb2.date_to = hr_general.end_of_time
AND htau.time_building_block_id = htb2.time_building_block_id
AND htau.time_building_block_ovn = htb2.object_version_number
AND htau.time_attribute_id = hta.time_attribute_id
AND papa.project_id = hta.attribute1
AND hts.start_time = htb.start_time
AND hts.start_time > sysdate - 380
AND hts.resource_id = htb.resource_id
AND htb.resource_id = :p_resource_id -- person_id
--AND hts.timecard_id = :p_timecard_id
AND hta.attribute_category = 'PROJECTS'
AND hts.approval_status = 'APPROVED'
AND hta.attribute2 = pt.task_id
AND hta.attribute1 = pt.project_id
ORDER BY htb1.start_time;
hts.stop_time, hts.submission_date,
htb1.start_time each_day, hta.attribute1 project_id,
hta.attribute2 task_id,papa.name, papa.segment1, pt.task_number, htb2.measure, pt.task_name
FROM hxc_time_building_blocks htb,
hxc_time_building_blocks htb1,
hxc_time_building_blocks htb2,
hxc_time_attribute_usages htau,
hxc_time_attributes hta,
pa_projects_all papa,
hxc_timecard_summary hts,
pa_tasks pt
WHERE htb1.parent_building_block_id = htb.time_building_block_id
AND htb1.parent_building_block_ovn = htb.object_version_number
AND htb.date_to = hr_general.end_of_time
AND htb.SCOPE = 'TIMECARD'
AND htb1.SCOPE = 'DAY'
--AND htb1.date_to = hr_general.end_of_time
AND htb2.parent_building_block_id = htb1.time_building_block_id
AND htb2.parent_building_block_ovn = htb1.object_version_number
AND htb2.SCOPE = 'DETAIL'
--AND htb2.date_to = hr_general.end_of_time
AND htau.time_building_block_id = htb2.time_building_block_id
AND htau.time_building_block_ovn = htb2.object_version_number
AND htau.time_attribute_id = hta.time_attribute_id
AND papa.project_id = hta.attribute1
AND hts.start_time = htb.start_time
AND hts.start_time > sysdate - 380
AND hts.resource_id = htb.resource_id
AND htb.resource_id = :p_resource_id -- person_id
--AND hts.timecard_id = :p_timecard_id
AND hta.attribute_category = 'PROJECTS'
AND hts.approval_status = 'APPROVED'
AND hta.attribute2 = pt.task_id
AND hta.attribute1 = pt.project_id
ORDER BY htb1.start_time;