Split functions in PL/SQL
As far as I know, PL/SQL does not have the split function. You need to write it yourself.
Code:
Create or replace type type_split as table of varchar2 (50); -- create a type. To make the split function more universal, set the size to a higher value. </P> <p> -- create function <br/> Create or replace function split <br/> (<br/> p_list varchar2, <br/> p_sep varchar2: = ',' <br/>) return type_split pipelined <br/> is <br/> l_idx pls_integer; <br/> v_list varchar2 (50): = p_list; <br/> begin <br/> loop <br/> l_idx: = instr (v_list, p_sep ); <br/> If l_idx> 0 then <br/> pipe row (substr (v_list, 1, l_idx-1); <br/> v_list: = substr (v_list, rochelle idx + Length (p_sep); <br/> else <br/> pipe row (v_list); <br/> exit; <br/> end if; <br/> end loop; <br/> return; <br/> end split;
Test:
SQL> select * from table (split ('northsnow, xue ',',')); </P> <p> column_value <br/> ------------------------------------------------ <br/> northsnow <br/> snow in Sebei </P> <p> SQL>
Original article: http://blog.csdn.net/precipitant/archive/2007/08/15/1744943.aspx.