oracle 字符串分割

 1 CREATE OR REPLACE TYPE str_split IS TABLE OF VARCHAR2 (4000);
 2 
 3 create or replace function strsplit2(p_value varchar2, p_split varchar2 := ',')
 4 return str_split
 5 pipelined is
 6 v_idx       integer;
 7 v_str       varchar2(500);
 8 v_strs_last varchar2(4000) := p_value;
 9 begin
10 loop
11 v_idx := instr(v_strs_last, p_split);
12 exit when v_idx = 0;
13 v_str       := substr(v_strs_last, 1, v_idx - 1);
14 v_strs_last := substr(v_strs_last, v_idx + 1);
15 pipe row(v_str);
16 end loop;
17 pipe row(v_strs_last);
18 return;
19 end strsplit2;

 

posted @ 2016-11-24 15:52  DemLiu  阅读(210)  评论(0编辑  收藏  举报