1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| WITH Chemin as
(
select 'A' as id_from, 'C' as id_to from dual union all
select 'C', 'A' from dual union all
select 'C', 'D' from dual union all
select 'D', 'C' from dual union all
select 'E', 'G' from dual union all
select 'G', 'E' from dual union all
select 'E', 'C' from dual union all
select 'C', 'E' from dual union all
select 'E', 'F' from dual union all
select 'F', 'E' from dual union all
select 'B', 'D' from dual union all
select 'D', 'B' from dual union all
select 'D', 'G' from dual union all
select 'G', 'D' from dual union all
select 'H', 'G' from dual union all
select 'G', 'H' from dual
)
select
connect_by_root id_from as root,
substr(sys_connect_by_path(id_from, '/'), 2) as path,
connect_by_isleaf as path_end
from Chemin
start with id_from in ('A', 'B', 'F', 'H')
connect by nocycle prior id_from = id_to
order siblings by path asc |
Partager