ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 转贴_字符串分隔_拆分

转贴_字符串分隔_拆分

原创 Linux操作系统 作者:wisdomone1 时间:2012-11-22 17:26:45 0 删除 编辑

http://atgc.itpub.net/post/22412/217030

 

create or replace type acc_type as object
(acc varchar2(50))
/

create or replace type acc_table as table of acc_type
/

create or replace function str2table (acc_str in varchar2) return acc_table pipelined
is
v_str varchar2(30000) := acc_str;
v_acc varchar2(30);
v_acc_end pls_integer;
begin
loop
v_acc_end := instrb(v_str,',');
exit when (v_acc_end=0 or v_str is null);
v_acc := substrb(v_str,1,v_acc_end-1);
v_str := ltrim(v_str,v_acc);
v_str := ltrim(v_str,',');
pipe row(acc_type(rtrim(v_acc,';')));
end loop;
return;
end;
/

SQL> select * from table(str2table('TEST1,TEST1,12,123,55,99MOON,'));

ACC
--------------------------------------------------
TEST1
TEST1
12
123
55
99MOON

6 rows selected.

SQL>

 

自己之前编写

http://space.itpub.net/9240380/viewspace-748309

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-749780/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
提供针对oracle初学者及进阶的数据库培训,欢迎大家咨询: 微信: wisdomone 微信公众号: lovedb 工作经历: 中国普天 北京科蓝 北京云和恩墨 北京神州新桥

注册时间:2008-04-04

  • 博文量
    2189
  • 访问量
    12690140