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 would I....

Re: How would I....

From: Jon Bon Jovi <sdkjf_at_aol.com>
Date: Mon, 03 Dec 2001 15:57:32 -0700
Message-ID: <3C0C035B.29D27142@aol.com>


Got it.

SQL> select * from test51;

NAME



LOT
#56
94

  1 select
  2 case
  3 when (name between 'A' and 'Z')

  4     then 1
  5     else 0

  6 end result
  7* from test51
SQL> /     RESULT
         1
         0
         0


It's miller time

koert54 wrote:

> Use some PL and let it throw an exception ...
>
> DECLARE
> result varchar2(x) ;
> num number ;
> BEGIN
>
> select to_number(substr(name,1,1)) into num from table ;
> -- no exception thrown ? it's a number
> select 'LOT' || name into result from table ;
>
> EXCEPTION
> WHEN ... THEN
> -- exception handling -> the first character is a char
> select name into result from table ;
> END
>
> "Jon Bon Jovi" <jon_at_bon.com> wrote in message
> news:3C0BFBDD.4ADDD91D_at_bon.com...
> > Take the first letter of a varchar2 column and determine if it's
> > a char or a number?
> > ie.
> >
> > select decode(substr(name,1,1),<IF STRING>,name,'LOT '||name) from table
> >
> > If the first char of the name column is a string then just use the name
> > column, otherwise
> > concatenate the word 'LOT ' to the beginning of the column.
> >
> > Thanks.
> >
> >
> >
> >
> >
> >
Received on Mon Dec 03 2001 - 16:57:32 CST

Original text of this message

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