Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to split strings in pl/sql or in sql/plus

Re: how to split strings in pl/sql or in sql/plus

From: Jeremy <newspostings_at_hazelweb.co.uk>
Date: Tue, 7 Jun 2005 09:19:09 +0100
Message-ID: <MPG.1d0f68cda0cf605a989ea9@news.individual.net>


In article <1118104516.241609.275800_at_g43g2000cwa.googlegroups.com>, baka says...
> hello
> I want to break the the follwoing string variable into two strings.
>
> eg; str="abcd\wxyz"
> into
> str1="abcd"
> str2="wxyz"
>
> i know how to do this in all 4GLs .
> is it possible to do it in SQL/PLUS or PL/SQL?
> (by the way i am re3ading a datfile from a .csv)
>

Well a PL/SQL solution taking literally the example you have supplied (running in sqlplus):

set serveroutput on size 999999

declare

  str 	varchar2(30) := 'abcd\wxyz';	   
  str1	varchar2(30); 
  str2	varchar2(30); 

--
begin
  str1 := substr(str,1,instr(str,'\')-1);   str2 := substr(str,instr(str,'\')+1);
  dbms_output.put_line(str1);
  dbms_output.put_line(str2);
end;
/

Hope that helps as an example.

-- 

jeremy
Received on Tue Jun 07 2005 - 03:19:09 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US