我需要在 pl/sql 中标记一个字符串并只返回唯一的标记。我已经看到了将字符串标记化的示例,但没有一个会返回唯一标记。
例如查询 -
select tokenize('hi you person person', ' ') as col1 from dual;
应该返回TOKEN_LIST('hi','you','person')
代替TOKEN_LIST('hi','you','person','person')
with t as (select 'aaaa bbbb cccc dddd eeee ffff aaaa' as txt from dual)
-- end of sample data
select DISTINCT REGEXP_SUBSTR (txt, '[^[:space:]]+', 1, level) as word
from t
connect by level <= length(regexp_replace(txt,'[^[:space:]]+'))+1;
上面的脚本产生以下结果:
WORD
dddd
eeee
bbbb
ffff
cccc
aaaa
这个想法是从OTN社区答案中无耻地窃取的。