You are on page 1of 2

select *

from
(
SELECT DISTINCT emp_hier.emp_level
, emp_hier.employee
, emp_hier.employee_jobname
, emp_hier.supervisor_name
, hou.name Op_Unit
--, pj.name Job_Name
, cf.control_function_name
, cg.control_group_name
--, cr.rule_type_code
--, cr.object_code
, to_char(cr.amount_limit) amount_limit
, (cr.segment1_low || '.' || cr.segment2_low || '.' ||
cr.segment3_low || '.' || cr.segment4_low || '.' ||
cr.segment5_low || '.' || cr.segment6_low || '.' ||
cr.segment7_low || '.' || cr.segment8_low || '.' ||
cr.segment9_low || '.' || cr.segment10_low || '.' ||
cr.segment11_low || '.' || cr.segment12_low) account_range_low,
(cr.segment1_high || '.' || cr.segment2_high || '.' ||
cr.segment3_high || '.' || cr.segment4_high || '.' ||
cr.segment5_high || '.' || cr.segment6_high || '.' ||
cr.segment7_high || '.' || cr.segment8_high || '.' ||
cr.segment9_high || '.' || cr.segment10_high || '.' ||
cr.segment11_high || '.' || cr.segment12_high) account_range_high
FROM
(
SELECT DISTINCT LEVEL Emp_Level
, PPF.FULL_NAME Employee
, PER_JOBS.NAME Employee_JobName
--, PERA.SUPERVISOR_ID
, (select ppf1.full_name from PER_ALL_PEOPLE_F PPF1 where person_id =
PERA.SUPERVISOR_ID) supervisor_name
--, PERA.PERSON_ID
--, SYS_CONNECT_BY_PATH(pera.person_id, '/') Path
-- Approval Related Values
/*, Approval_Limit.control_function_name
, Approval_Limit.control_group_name
, Approval_Limit.rule_type_code
, Approval_Limit.object_code
, Approval_Limit.amount_limit
, Approval_Limit.account_range_low
, Approval_Limit.account_range_high*/
FROM PER_ASSIGNMENTS_F PERA
, PER_JOBS
, PER_ALL_PEOPLE_F PPF
WHERE 1 = 1
AND PER_JOBS.JOB_ID = PERA.JOB_ID
AND TRUNC(SYSDATE) BETWEEN trunc(PPF.EFFECTIVE_START_DATE) AND
trunc(PPF.EFFECTIVE_END_DATE)
AND PPF.PERSON_ID = PERA.PERSON_ID
AND EXISTS (SELECT '1'
FROM PER_PEOPLE_F PERF
, PER_ASSIGNMENTS_F PERA1
WHERE 1 = 1
AND TRUNC(SYSDATE) BETWEEN TRUNC(PERF.EFFECTIVE_START_DATE) AND
TRUNC(PERF.EFFECTIVE_END_DATE)
AND PERF.PERSON_ID = PERA.SUPERVISOR_ID
AND PERA1.PERSON_ID = PERF.PERSON_ID
AND TRUNC(SYSDATE) BETWEEN TRUNC(PERA1.EFFECTIVE_START_DATE) AND
TRUNC(PERA1.EFFECTIVE_END_DATE)
AND PERA1.PRIMARY_FLAG = 'Y'
AND PERA1.ASSIGNMENT_TYPE = 'E'
AND EXISTS (SELECT '1'
FROM PER_PERSON_TYPES PPT
WHERE 1 = 1
AND PPT.SYSTEM_PERSON_TYPE IN ('EMP','EMP_APL')
AND PPT.PERSON_TYPE_ID = PERF.PERSON_TYPE_ID
)
)
START WITH PERA.PERSON_ID = 94325 -- Person Id for the Employee
AND TRUNC(SYSDATE) BETWEEN TRUNC(PERA.EFFECTIVE_START_DATE) AND
TRUNC(PERA.EFFECTIVE_END_DATE)
AND PERA.PRIMARY_FLAG = 'Y'
AND PERA.ASSIGNMENT_TYPE = 'E'
CONNECT BY NOCYCLE PRIOR PERA.SUPERVISOR_ID = PERA.PERSON_ID
AND TRUNC(SYSDATE) BETWEEN TRUNC(PERA.EFFECTIVE_START_DATE) AND
TRUNC(PERA.EFFECTIVE_END_DATE)
AND PERA.PRIMARY_FLAG = 'Y'
AND PERA.ASSIGNMENT_TYPE = 'E'
-- AND LEVEL <= 4
--
--AND PER_JOBS.NAME = Approval_Limit.Job_Name
--
-- ORDER BY 1
) emp_hier
, po_position_controls_all pc,
po_control_groups_all cg,
po_control_functions cf,
po_control_rules cr,
per_jobs pj,
hr_all_organization_units hou
WHERE 1 = 1
AND pc.control_group_id = cg.control_group_id
AND cr.control_group_id = pc.control_group_id
AND pc.control_function_id = cf.control_function_id
AND pc.org_id = hou.organization_id
AND trunc(SYSDATE) BETWEEN pc.start_date AND
nvl(pc.end_date, SYSDATE + 1)
AND cf.enabled_flag = 'Y'
AND cg.enabled_flag = 'Y'
AND pj.job_id = pc.job_id
AND hou.name = 'ST Holland'
AND emp_hier.employee_jobname = pj.name
order by 1, cf.control_function_name
)
where 1 = 1
and account_range_low <> '...........'
;

You might also like