oracle 数据库split 函数,将数据切割返回成表格形式

1. oracle 数据库 split(a,b) 函数

具体代码参考如下:

select * from table(split('2#3#4#5#',‘#’))

其中p_list :为传入参数
p_sep:为需要切割的标记,如 ‘,’ , ‘ # ’ ,‘ / ’等等

create or replace function split(p_list in varchar2, p_sep in varchar2)  return type_split pipelined
IS
 j int := 0;
 i int := 1;
 len int := 0;
 len1 int := 0;
 v_list varchar2(5000);
BEGIN
 len := length(p_list);
 len1 := length(p_sep);
 while j < len 
  loop 
   j :=INSTR(p_list,p_sep,i);
    if j = 0 then
     j := len;
     v_list := substr(p_list,i) ;
     pipe row(v_list);
      if i > len then
       exit;
       end if;
     else
      v_list := substr(p_list,i,j - i);
      i := j + len1;
      pipe row(v_list);
      end if;
      end loop;
      return;
   end split;     

具体结果参考下图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值