最近从Excel中到了一些数据,结果一个列的数据是以逗号分隔的字符串,想把它拆分开找到了下边的方法,贴出来分享一下:
CREATE OR REPLACE PROCEDURE sptstr (srcstr varchar2) as
stmp varchar2(2000);
begin
select srcstr into stmp from dual;
while nvl(length(stmp),0) > 1
loop
insert into tabtest(col) select substr(stmp,1,instr(stmp,',')-1 ) from dual;
select substr(stmp,instr(stmp,',')+1) into stmp from dual;
end loop ;
commit;
end sptstr;
想要拆分用其它分隔符连接的字符串也可以,只要修改instr函数中的第二个参数就好了!