oracle split函数实现,按顺序获取,两个字符直接的空值也能获取

2016-12-30 11:26:38来源:CSDN作者:u012248264人点击

参考了网上的代码修改实现,修改后可以按顺序获取数组

with str as (select 'first field,,second field,,third field,' as text,',' as split_ch from dual where rownum = 1)select case         when text = ' ' then          null         else          replace(text, '  ', ' ')       end text,       indext  from (SELECT REGEXP_SUBSTR(replace(replace(str.text, ' ', '  '),                                     str.split_ch || str.split_ch,                                     str.split_ch || ' ' || str.split_ch),                             '[^' || str.split_ch || ']+',                             1,                             rownum) AS TEXT,               ROWNUM AS INDEXT          FROM dual, str        CONNECT BY ROWNUM <= LENGTH(str.text) -                   LENGTH(REPLACE(str.text, str.split_ch, '')) + 1) ORDER BY INDEXT

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台