-- 分隔字段
create or replace procedure substring_array2(str in varchar2) as
type array_str is table of varchar2(100) index by binary_integer;
myarray array_str;
v_str varchar2(4000) default str;
begin
-- i in 0..单位总数(除去连接符)
for i in 0 .. length(str) - length(replace(str, ',', '')) + 1 loop
-- 第一个符号出现的位置
if instr(v_str, ',') = 0 then
myarray(i + 1) := v_str;
else
myarray(i + 1) := substr(v_str, 0, instr(v_str, ',') - 1);
end if;
v_str := substr(v_str, instr(v_str, ',') + 1);
end loop;
for i in 0 .. length(str) - length(replace(str, ',', '')) loop
dbms_output.put_line(myarray(i + 1));
insert into t_p values (myarray(i + 1));
commit;
end loop;
end substring_array2;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12961536/viewspace-769590/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12961536/viewspace-769590/