字串分割成多行資料(oracle函數),多行oracle

來源:互聯網
上載者:User

字串分割成多行資料(oracle函數),多行oracle

原文地址——http://blog.csdn.net/qq525099302/article/details/47146537

-- 建立分割類型(函數中要用到)create or replace type strsplit_type as table of varchar2(4000) ;-- 建立分割函數create or replace function strsplit(p_value varchar2,                                    p_split varchar2 := ',')--usage: select * from table(strsplit('1,2,3,4,5')) return strsplit_type  pipelined is  v_idx       integer;  v_str       varchar2(500);  v_strs_last varchar2(4000) := p_value;begin  loop    v_idx := instr(v_strs_last, p_split);    exit when v_idx = 0;    v_str       := substr(v_strs_last, 1, v_idx - 1);    v_strs_last := substr(v_strs_last, v_idx + 1);    pipe row(v_str);  end loop;  pipe row(v_strs_last);  return;end strsplit;

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.