还有一个变种:
with t as
( select
'1,2,3' as char1,
'1,2,3,4,5' as char2
from dual )
select listagg(coalesce(a.parsed_char,b.parsed_char),',') within group (order
by 1) as res
from ( select regexp_substr(char1, '[^,]+',1,level) as parsed_char
from t
connect by regexp_substr(char1, '[^,]+',1,level) is not null ) a
full join
( select regexp_substr(char2, '[^,]+',1,level) as parsed_char
from t
connect by regexp_substr(char2, '[^,]+',1,level) is not null ) b
on (a.parsed_char = b.parsed_char)
where a.parsed_char is null or b.parsed_char is null;