Objective:

To split the given string separated by special character as an individual column value using oracle pipelined Function.

Step 1:

Create table type of varchar:

 

create or replace type split_tbl as table of varchar2(32767);

 

Step 2:

Create a Pipelined function as below:

create or replace function split

(

p_list varchar2,

p_del varchar2 := ‘,’

) return split_tbl pipelined

is

l_idx    pls_integer;

l_list    varchar2(32767) := p_list;

l_value    varchar2(32767);

begin

loop

l_idx := instr(l_list,p_del);

if l_idx > 0 then

pipe row(substr(l_list,1,l_idx-1));

l_list := substr(l_list,l_idx+length(p_del));

 

else

pipe row(l_list);

exit;

end if;

end loop;

return;

end split;

 

Step 3:

Get the Comma separated value as separate row value as below.

 

SELECT COLUMN_VALUE my_string FROM TABLE (split(‘Aishwarya,Aish,A’));

Output:

 

Recommended Posts

Start typing and press Enter to search