/*
参数说明:
输入:
srcStr;待分割字串; 例子:1;2;3;45;46;
splitStr:分隔符
功能说明:输出分隔符前字串
演示:
sql>set serveroutput on;
sql>exec splitStr('12;34;56;',';');
12
34
56
*/ create or replace procedure splitStr(srcStr IN VARCHAR2,splitStr IN VARCHAR2) IS
sposition1 INTEGER;
sposition2 INTEGER;
mysubstr VARCHAR2(10);
starttimes INTEGER;
begin
starttimes:=1;
sposition1:=1;
loop
sposition2:=instr(srcStr,splitStr,1,starttimes);
exit when sposition2=0;
mysubstr:=substr(srcStr,sposition1,sposition2-sposition1);
sposition1:=sposition2+1;
starttimes:=starttimes+1;
dbms_output.put_line(mysubstr);
end loop;
dbms_output.put_line('end');
end ;
标签:分隔,sposition1,sposition2,splitStr,字符串,VARCHAR2,srcStr,oracle,starttimes
From: https://blog.51cto.com/u_16065168/6183031