oracle以指定符号切割字符串并以行的形式返回切割结果
CREATE OR REPLACE TYPE string_table_type IS TABLE OF VARCHAR2(4000);
CREATE OR REPLACE FUNCTION split_string_pipelined (
p_string VARCHAR2,
p_delimiter VARCHAR2
)
RETURN string_table_type PIPELINED
IS
v_start PLS_INTEGER := 1;
v_end PLS_INTEGER;
v_substring VARCHAR2(4000);
BEGIN
LOOP
v_end := INSTR(p_string, p_delimiter, v_start);
IF v_end = 0 THEN
v_substring := SUBSTR(p_string, v_start);
PIPE ROW(v_substring);
EXIT;
ELSE
v_substring := SUBSTR(p_string, v_start, v_end - v_start);
PIPE ROW(v_substring);
v_start := v_end + LENGTH(p_delimiter);
END IF;
EXIT WHEN v_start > LENGTH(p_string);
END LOOP;
RETURN;
END split_string_pipelined;
/