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 28 29 30 31 32 33 34 35 36
| SQL> with t as (
select 'l1' as c1, 'x1,x2,x3' as c2 from dual union all
select 'l2' , 'x3,x4' from dual union all
select 'l5' , 'x5' from dual union all
select 'l5' , 'x1,x4,x6,x7' from dual
)
select t.c1, x.column_value as list_c2
from t
cross join table(
cast(multiset(
select substr( ','||c2||',',
instr( ','||c2||',', ',', 1, rownum )+1,
instr( ','||c2||',', ',', 1, rownum+1 )
-instr( ','||c2||',', ',', 1, rownum )-1
)
from dual
connect by level <= length(c2)-length(replace(c2,',',''))+1
) as sys.odcivarchar2list )
) x;
C1 LIST_
-- -----
l1 x1
l1 x2
l1 x3
l2 x3
l2 x4
l5 x5
l5 x1
l5 x4
l5 x6
l5 x7
10 rows selected.
SQL> |
Partager