第一种
create or replace function split(p_str in varchar2, -- 要分割的字符串
p_delimiter in varchar2 default (',')) -- 分隔符,默认为','
return split_type is
j int := 0;
i int := 1;
len int := 0;
len1 int := 0;
str varchar2(4000);
my_split split_type := split_type();
begin
len := length(p_str);
len1 := length(p_delimiter);
while j < len loop
j := instr(p_str, p_delimiter, i);
if j = 0 then
j := len;
str := substr(p_str, i);
my_split.extend;
my_split(my_split.count) := str;
if i >= len then
exit;
end if;
else
str := substr(p_str, i, j - i);
i := j + len1;
my_split