Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help, Split string to columns

1013506Jun 7 2013 — edited Jun 7 2013
i have this string (string1,string2|string1,string2)

i need to split it like this:

COLUMN 1 COLUMN2
string1 string2
string1 string 2

some help?

i was creating a function but i need some help


create or replace
Function String_To_Columns(
Pv_String In Varchar2,
Pv_Delimiter_Columns In Varchar2 Default ',',
pv_delimiter_rows in varchar default '|'
)
RETURN tab_varchar2 PIPELINED
AS
lv_string VARCHAR2( 32767 ) DEFAULT pv_string || pv_delimiter_rows;
lv_num PLS_INTEGER;
BEGIN

IF lv_string = Pv_Delimiter_Columns then
Return;
end if;

LOOP
lv_num := INSTR( lv_string, pv_delimiter_rows);
Exit When ( Nvl( Lv_Num, 0 ) = 0 );
Pipe Row( Ltrim( Rtrim( Substr( Lv_String, 1, Lv_Num - 1 ))));
Lv_String := Ltrim( Substr( Lv_String, Lv_Num + 1 ));
END LOOP;

Return;
END;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2013
Added on Jun 7 2013
4 comments
5,116 views