oracle split函数
create or replace type type_split as table of varchar2(2000); --创建数组
create or replace function split
(p_list varchar2,p_sep varchar2 := ',') return type_split pipelined
is
l_idx pls_integer;
v_list varchar2(50) := p_list;
begin
loop
l_idx := instr(v_list,p_sep);
if l_idx > 0 then
pipe row(substr(v_list,1,l_idx-1));
v_list := substr(v_list,l_idx+length(p_sep));
else
pipe row(v_list);
exit;
end if;
end loop;
return;
end split;
测试:
SQL> select * from table(split('测试一,测试二',','));