我有一个包含以下格式的列数据的表(Row#只是为了表示行号).
Row#1 :test.doc#delimiter#1234,test1.doc#delimiter#1235,test2.doc#delimiter#1236<br> Row#2 :fil1.txt#delimiter#1456,fil1.txt#delimiter#1457
我想使用逗号(,)作为分隔符来分割字符串,在一个列中列出所有字符串并插入到新表中.
输出应该是这样的(行#只是为了表示行号):
Row#1:test.doc#delimiter#1234<br> Row#2:test1.doc#delimiter#1235<br> Row#3:test2.doc#delimiter#1236<br> Row#4: fil1.txt#delimiter#1456
任何人都可以帮我这样做吗?
解决方法
WITH data AS ( SELECT 'test.doc#delimiter#1234,test2.doc#delimiter#1236' AS "value" FROM DUAL UNION ALL SELECT 'fil1.txt#delimiter#1456,fil1.txt#delimiter#1457' AS "value" FROM DUAL ) SELECT REGEXP_SUBSTR( data."value",'[^,]+',1,levels.COLUMN_VALUE ) FROM data,TABLE( CAST( MULTISET( SELECT LEVEL FROM DUAL CONNECT BY LEVEL <= LENGTH( regexp_replace( "value",]+')) + 1 ) AS sys.OdciNumberList ) ) levels;