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: PL/SQL substr(instr oracle

Re: PL/SQL substr(instr oracle

From: Rauf Sarwar <member31517_at_dbforums.com>
Date: Fri, 20 Jun 2003 01:44:15 +0000
Message-ID: <3023669.1056073455@dbforums.com>

Originally posted by Nuno Souto
> wizofoz2k_at_yahoo.com.au (Nuno Souto) wrote in message
> news:news:...
> >
> > this is better than my previous attempt:
> >
>
>
>
> Apologies:
>
> select substr('&STR',1,instr('&STR','_')-1||
> translate(initcap(replace(substr('&STR',instr
> ('&STR','_')),'_',' ')),' abcdefghijklmnopqrstuvwxyz','_')
> from dual;
>
>
>
> Cheers
> Nuno Souto
> wizofoz2k_at_yahoo.com.au.nospam

Good improvement Nuno. Uppercase alphabet in my original query was a bit much... but heck... it did work -:)

However, your query from previous post results in, YC_C_I_M_C

and your above query is missing a ) after -1 and also results in, YC C I M C

Here is the improvement to your above query... You need outside replace to remove spaces and you don't need -1 in first substr,

select replace(substr('&STR',1,instr('&STR','_'))|| translate(initcap(replace(substr('&STR',instr ('&STR','_')),'_',' ')),'abcdefghijklmnopqrstuvwxyz','_'), ' ', '') as string
from dual;

and yes... I would like to see how Sql Server or DB2 can do this.

Regards
/Rauf Sarwar

--
Posted via http://dbforums.com
Received on Thu Jun 19 2003 - 20:44:15 CDT

Original text of this message

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