现在我要select a from t
这个a列中既有1也有1,2,3这样用逗号分隔的数
现在我要把这些不管有用逗号分隔还是没有的都作为一个单独的字段加入一个游标或者数组做循环之用
要怎么办?
------解决思路----------------------
以下的SQL是分隔A中的数字
select rn
REGEXP_SUBSTR(a, '[^,]+', 1, LEVEL) STR
from (select a,rownum rn from t)
CONNECT BY LEVEL <= REGEXP_COUNT( a, ',') + 1
and rn= prior rn
and prior dbms_random.value is not null;
注意:regexp_count在11g以后才能使用,如果是11g以前需换成
length(a)-length(replace(a,',',''))