首页 > 其他 > 详细

逗号分隔的字符串转换为行数据(collection)

时间:2016-12-03 14:57:57      阅读:129      评论:0      收藏:0      [点我收藏+]
逗号分隔的字符串转换为行数据(collection)
 
CREATE OR REPLACE FUNCTION "GET_STR_TAB" (v_str in varchar2) return table_str pipelined as
  v_new_str varchar2(8000);
begin
  if v_str is null then
    pipe row(-1);
  else
    v_new_str:=replace(replace(v_str,chr(10),‘‘),chr(9),‘‘);
    while 1=1 loop
      if instr(v_new_str,,)=0 then
        pipe row(to_number(v_new_str));
        exit;
      else
        pipe row(to_number(substr(v_new_str,1,instr(v_new_str,,)-1)));
        v_new_str:=substr(v_new_str,instr(v_new_str,,)+1);
      end if;
    end loop;
  end if;
  return;
end;
 
另还要有一个type类型
CREATE OR REPLACE TYPE "TABLE_STR"       as table of number

 

逗号分隔的字符串转换为行数据(collection)

原文:http://www.cnblogs.com/alsf/p/6128572.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!