SELECT DISTINCT LPAD (' ', LEVEL * 2) || LEVEL
, CONNECT_BY_ROOT hp1.party_name AS ROOT
, SYS_CONNECT_BY_PATH(hp1.party_name, ':') AS CHAIN
, hp1.party_name parent_party
, hp1.party_id parent_party_id
, hp1.party_number parent_party_number
, hp.party_name child_party
, hp.party_id child_party_id
, hp.party_number child_party_number
FROM hz_relationships hr
, hz_parties hp
, hz_parties hp1
WHERE object_id = hp.party_id
AND hp1.party_id = hr.subject_id
AND hp.status = 'A'
AND hr.status = 'A'
AND hr.direction_code = 'P'
AND relationship_type = :p_hierarchy_type
START WITH hp1.party_id = :p_parent_party_id
AND relationship_type = :p_hierarchy_type
AND hr.status = 'A'
CONNECT BY NOCYCLE PRIOR hr.object_id = hr.subject_id
AND hr.object_type = PRIOR hr.subject_type
AND hr.object_table_name = PRIOR hr.subject_table_name
AND hr.direction_code = 'P'
AND hr.status = 'A'
ORDER SIBLINGS BY hp.party_name
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.