1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| With MaTable as
(
select 1 ide, 'entité1' lbe, 2 idp, 1 idt from dual union all
select 2 , 'entité2' , 3 , 4 from dual union all
select 3 , 'entité3' , 4 , 6 from dual union all
select 4 , 'entité4' , null , 9 from dual union all
select 5 , 'entité5' , 6 , 1 from dual union all
select 6 , 'entité6' , 7 , 4 from dual union all
select 7 , 'entité7' , null , 9 from dual
)
select lbe as libelle_final,
connect_by_root lbe as libelle_initial,
connect_by_root ide as id_initial
from MaTable
where connect_by_isleaf = 1
START with idp is null
and idt = 9
CONNECT BY PRIOR ide = idp;
LIBELLE_FINAL LIBELLE_INITIAL ID_INITIAL
entité1 entité4 4
entité5 entité7 7 |
Partager