字符串分割函数

--本文摘自klyuan

  1. Parameters:   
  2.    pi_string 要处理的字符   
  3.   pi_separator 分隔符   
  4.   pi_count 第n个分隔符   
  5. function get_part_char(pi_string in varchar2, pi_separator in varchar2, pi_count number) return varchar2 is  
  6.   pos number;   
  7.   c_pos number;   
  8. begin  
  9.   if pi_string is null or pi_separator is null then  
  10.      return '';   
  11.  end if;   
  12.     
  13.   if pi_count < 1 then  
  14.      return '';   
  15.   end if;   
  16.  if pi_count = 1 then  
  17.     pos := instr(pi_string, pi_separator);   
  18.     if pos = 0 then  
  19.         return pi_string;   
  20.     else  
  21.       return substr(pi_string,0,pos-1);   
  22.     end if;   
  23.   else  
  24.      pos := instr(pi_string, pi_separator,1,pi_count -1);   
  25.      c_pos := instr(pi_string, pi_separator, 1, pi_count)   
  26.      if pos = 0 then  
  27.         return '';   
  28.      end if;   
  29.      if c_pos = 0 then  
  30.          return substr(pi_string, pos+1, length(pi_string) - pos);   
  31.      else  
  32.         return substr(pi_string, pos+1, c_pos - pos -1);   
  33.      end if;   
  34.   end if;   
  35. end get_part_char;  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值