这个函数要用到,记录下
create or replace function split(src varchar2, delimiter varchar2)--src 分割的字符串,delimiter 分隔符
return t_str20list is
psrc varchar2(500);
a t_str20list := t_str20list();
i number := 1;
j number := 1;
begin
psrc := rtrim(ltrim(src, delimiter), delimiter);
loop
i := instr(psrc, delimiter, j);
if i > 0 then
a.extend;
a(a.count) := trim(substr(psrc, j, i - j));
j := i + 1;
end if;
exit when i = 0;
end loop;
if j < length(psrc) then
a.extend;
a(a.count) := trim(substr(psrc, j, length(psrc) + 1 - j));
end if;
return a;
end;
调用它的存储过程
select tinvnos.column_value as invno, sivo.invid
from sellinvoice sivo,
table (select split(t.invnos, ',')
from sellinvoice t
where t.invid = sivo.invid) as tinvnos