preface
1. The regexp_substr function is used to split the string by regularization. The function usage is: (It must be supported by the version of Oracle 10g+)
function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)
select bs from cs1_0 where slid='201804100038' --First value after regular segmentation SELECT REGEXP_SUBSTR ((select bs from cs1_0 where slid='201804100038'), '[^,]+', 1,1, 'i') as the result after segmentation FROM DUAL; --Get a column with multiple values, so that the results can be displayed in multiple rows SELECT LEVEL FROM DUAL CONNECT BY LEVEL <=5; --Implement dynamic parameters by using the occurrence of REGEXP_SUBSTR above (identifying the first matching group), and combine them with connect by SELECT REGEXP_SUBSTR ((select bs from cs1_0 where slid='201804100038'), '[^,]+', 1, LEVEL, 'i') as the result after segmentation FROM DUAL CONNECT BY LEVEL<=5; --Optimize it (dynamically obtain the number of matching group ID lines) Select regexp_substr ((select bs from cs1_0 where slid='201804100038'), '[^,]+', 1, LEVEL, 'i') as the result after segmentation from dual connect by level <= length((select bs from cs1_0 where slid='201804100038'))-length(regexp_replace((select bs from cs1_0 where slid='201804100038'),',',''))+1;
2. Implemented in the form of Type and function function
1) Create Type CREATE OR REPLACE TYPE strsplit_type_12 IS TABLE OF VARCHAR2 (4000) 2) Create function storage function Create or replace function strsplit_66 (p_value varchar2, p_split varchar2) -- string, cutter --Cutting strings according to specific characters return strsplit_type_12 pipelined is v_idx integer; v_str varchar2(500); v_strs_last varchar2(4000) := p_value; begin loop v_idx := instr(v_strs_last, p_split); exit when v_idx = 0; v_str := substr(v_strs_last, 1, v_idx - 1); v_strs_last := substr(v_strs_last, v_idx + 1); pipe row(v_str); end loop; pipe row(v_strs_last); return; end strsplit_66; SELECT ROWNUM S/N, a. * FROM TABLE (strsplit_66 ((select bs from cs1_0 where slid='201804100038'), ',')) a;