Chinaunix首页 | 论坛 | 博客
  • 博客访问: 28081
  • 博文数量: 10
  • 博客积分: 400
  • 博客等级: 下士
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-30 09:57
文章分类

全部博文(10)

文章存档

2011年(1)

2009年(2)

2008年(7)

我的朋友

分类: Oracle

2008-12-23 11:13:27

第一,先创建一个Type
 
 

CREATE OR REPLACE TYPE type_split IS TABLE OF VARCHAR2 (4000)

 

第二,创建函数

 

create or replace function split(p_list varchar2,p_sep varchar2 := ',') return type_split pipelined
IS
 l_idx pls_integer;
 v_list varchar2(50) := p_list;

 begin
      loop
           l_idx := instr(v_list,p_sep);
           if l_idx > 0 then
               pipe row(substr(v_list,1,l_idx-1));
               v_list := substr(v_list,l_idx+length(p_sep));
           else
                pipe row(v_list);
                exit;
           end if;

      end loop;


      return;
 end split;

 

第三,调试

 

select * from table(split('aaa,bbb,ccc',','))

阅读(631) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~