oracle split function
2022-03-17 12:31 tshaoguo 阅读(50) 评论(0) 编辑 收藏 举报create or replace function get_split
(
f_str varchar2,
s_str varchar2,
num number
)
return varchar2
as
p1 number(10);
p2 number(10);
len number(10);
r_str varchar2(255);
begin
if(num<=0) then
p1:=0;
p2:=0;
elsif(num=1) then
p1:=0;
p2:=instr(f_str,s_str,1,num);
elsif(num>1) then
p1:=instr(f_str,s_str,1,num-1);
p2:=instr(f_str,s_str,1,num);
end if;
if(p2=0 and p1!=0) then
p2:=length(f_str)+1;
end if;
len:=p2-p1-1;
r_str:=substr(f_str,p1+1,len);
return r_str;
end get_split;