Query of Position Hierarchy
SELECT DISTINCT
CONNECT_BY_ROOT (PARENT_POSITION_ID) perant_id,
HR_GENERAL.DECODE_POSITION_LATEST_NAME (parent_POSITION_ID)
direct_parent_name,
SUBORDINATE_POSITION_ID child_id,
HR_GENERAL.DECODE_POSITION_LATEST_NAME (SUBORDINATE_POSITION_ID)
child_name,
---------------------------------
SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/') PATH,
---------------------------------
HR_GENERAL.DECODE_POSITION_LATEST_NAME (
REPLACE (
SUBSTR (
SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'),
0,
INSTR (SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'),
'/',
2)),
'/',
NULL))
substr_parent_name,
---------------------------------
HR_GENERAL.DECODE_POSITION_LATEST_NAME (
SUBSTR (SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'), 2, 4))
parent_name,
---------------------------------
LEVEL "LVL",
BUSINESS_GROUP_ID
FROM PER_POS_STRUCTURE_ELEMENTS ss
WHERE SUBORDINATE_POSITION_ID = :pchild_id -- 4101
-- AND LEVEL > (8)-3
CONNECT BY NOCYCLE PRIOR SUBORDINATE_POSITION_ID = parent_POSITION_ID --PRIOR
START WITH --LEVEL = 0
( SUBORDINATE_POSITION_ID) IS NOT NULL
AND (PARENT_POSITION_ID) IS NOT NULL
ORDER BY LEVEL DESC
SELECT DISTINCT
CONNECT_BY_ROOT (PARENT_POSITION_ID) perant_id,
HR_GENERAL.DECODE_POSITION_LATEST_NAME (parent_POSITION_ID)
direct_parent_name,
SUBORDINATE_POSITION_ID child_id,
HR_GENERAL.DECODE_POSITION_LATEST_NAME (SUBORDINATE_POSITION_ID)
child_name,
---------------------------------
SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/') PATH,
---------------------------------
HR_GENERAL.DECODE_POSITION_LATEST_NAME (
REPLACE (
SUBSTR (
SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'),
0,
INSTR (SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'),
'/',
2)),
'/',
NULL))
substr_parent_name,
---------------------------------
HR_GENERAL.DECODE_POSITION_LATEST_NAME (
SUBSTR (SYS_CONNECT_BY_PATH (SUBORDINATE_POSITION_ID, '/'), 2, 4))
parent_name,
---------------------------------
LEVEL "LVL",
BUSINESS_GROUP_ID
FROM PER_POS_STRUCTURE_ELEMENTS ss
WHERE SUBORDINATE_POSITION_ID = :pchild_id -- 4101
-- AND LEVEL > (8)-3
CONNECT BY NOCYCLE PRIOR SUBORDINATE_POSITION_ID = parent_POSITION_ID --PRIOR
START WITH --LEVEL = 0
( SUBORDINATE_POSITION_ID) IS NOT NULL
AND (PARENT_POSITION_ID) IS NOT NULL
ORDER BY LEVEL DESC