In my previous post, I used "CONNECT BY" clause.
SQL: Delimited list of values as in-line view. csv on memory (INOUE Katsumi @ Tokyo)
select regexp_substr('KING,TURNER,BLAH,!ERROR!,0,JAMES','[^,]+',1,level) as token
from dual connect by level <= 256
But after reading very informative blog page below, I decided to rewrite it.
About Oracle: Recursive subquery factoring
Version 11g release 2 introduced recursive subquery factoring or the recursive with clause.
Here's my result. I stared at this SQL for 10 minutes but I didn't come up with any smarter one.
Of course, I may be wrong.
SQL>var string varchar2(256)SQL>exec :string := 'aa,b_b,cc cc,dddd:ddd' PL/SQL procedure successfully completed. SQL>with tokens(token, level_num) as2(select regexp_substr(:string,'[^,]+',1,1),1 from dual3union all4select regexp_substr(:string,'[^,]+',1,level_num+1),level_num+1 from tokens5where level_num < 256)6select token from tokens where token is not null7/ aa b_b cc cc dddd:ddd