oracle 字符串转行

CREATE TABLE t_str_row(ID INT,str VARCHAR2(50));

 

INSERT INTO t_str_row VALUES (1, 'v11|$|v12|$|v13|$|');

 

SELECT c.lv, rtrim(regexp_substr(t.str, '.*?\|\$\|', 1, c.lv),'\|\$\|') AS cv from (SELECT str,length(regexp_replace(str,'[^'||chr(124)||chr(36) || chr(124) || ']',NULL)) / 3 AS cnt FROM t_str_row where id = '1') t INNER JOIN (SELECT LEVEL lv FROM dual CONNECT BY LEVEL <=(SELECT length(regexp_replace(str,'[^'||chr(124)||chr(36)||chr(124) || ']',NULL)) / 3 AS cnt FROM t_str_row where id = '1')) c ON c.lv <=t.cnt;

 

你可能感兴趣的:(oracle)