create or replace function basedba.ac_get_splitstr(
I_str IN VARCHAR2,
I_num IN number) return varchar2 is
str1 VARCHAR2(100);
i integer;
i1 integer;
begin
str1:=' ';
begin
if I_num=1 then i:=0; else i:=instr(I_str,'|',1,I_num-1); end if;
i1:=instr(I_str,'|',1,I_num);
if i>=length(I_str) or i1>length(I_str) then str1 := ' ';
else
select substr(I_str,
i+1,
decode(i1,0,length(I_str)+1,i1)-i-1)
into str1 from dual;
end if;
exception when others then
null;
end;
return str1;
end ac_get_splitstr;
select ac_get_splitstr('fgggg|114|147|477|17147|77|1111',7) from dual;