oracle 数据库 分割字符串返回结果集函数
CREATE OR REPLACE FUNCTION "UFN_SPLIT" ( p_list varchar2, p_sep varchar2 := ‘,‘ ) return TYPE_SPLIT pipelined is l_idx pls_integer; v_list varchar2(4000) := p_list; v_num number(18,0) := 1; o_TABLESPLIT OBJ_TABLESPLIT ; begin loop
l_idx := instr(v_list,p_sep); if l_idx > 0 then
o_TABLESPLIT := OBJ_TABLESPLIT(v_num,substr(v_list,1,l_idx-1)); pipe row(o_TABLESPLIT); v_list := substr(v_list,l_idx+length(p_sep)); else o_TABLESPLIT := OBJ_TABLESPLIT(v_num,v_list); pipe row(o_TABLESPLIT); exit; end if; v_num := v_num + 1; end loop; return;
END UFN_SPLIT;
CREATE OR REPLACE TYPE "OBJ_TABLESPLIT" as object
(
sIndex NUMBER(18,0),
sValue varchar2(200)
);
CREATE OR REPLACE TYPE "TYPE_SPLIT" is table of OBJ_TABLESPLIT
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。