Den korrekte operator for strengsammenligninger er LIKE. Bemærk, at det virker for CLOB'er, ikke kun for VARCHAR2.
I eksemplet nedenfor opretter jeg tabellen med inputstrenge i farten ved hjælp af en bestemt metode. Der er flere andre metoder - brug den, du kender.
with
a_x ( a, b ) as (
select to_clob('atveroeosipsumloremipsumdolor'), 1 from dual union all
select to_clob('stetclitakasdtest') , 2 from dual union all
select to_clob('noseatakimataatveroeosipsum') , 3 from dual union all
select to_clob('loremipsumdolor') , 4 from dual union all
select to_clob('consetetursadipscingelitr') , 5 from dual
),
input_strings ( str ) as (
select column_value
from table ( sys.odcivarchar2list ( 'atveroeosipsum', 'test', 'stetclitakasd',
'noseatakimata', 'loremipsumdolor',
'consetetursadipscingelitr'
)
)
)
select t2.str, listagg(t1.b, ',') within group (order by t1.b) as ids
from a_x t1
join input_strings t2 on t1.a like '%' || t2.str || '%'
group by t2.str
;
STR IDS
------------------------- ---
atveroeosipsum 1,3
consetetursadipscingelitr 5
loremipsumdolor 1,4
noseatakimata 3
stetclitakasd 2
test 2