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: anyone way to use a wildcard in a decode?

Re: anyone way to use a wildcard in a decode?

From: Ryan <rgaffuri_at_cox.net>
Date: Thu, 12 Jun 2003 02:37:22 GMT
Message-ID: <CHRFa.7281$Id7.4612@news2.east.cox.net>

"Anurag Varma" <avdbi_at_hotmail.com> wrote in message news:jBQFa.1071$1i6.395_at_news02.roc.ny.frontiernet.net...
> 8i onwards:
> select
> case
> when y like '%A%' then 'XXXXX'
> else 'BLAH'
> end as y
> from xx
>
>
> I think DECODE is going to be deprecated in future versions.
> A boring way to do this via decode will be:
> select decode(instr(y,'A',1),0,'BLAH','XXXXX') from xx;
>
> Anurag
>
> "Ryan Gaffuri" <rgaffuri_at_cox.net> wrote in message
news:1efdad5b.0306111155.78871856_at_posting.google.com...
> > If I can manage this, I can condense about 10 insert statements into
> > one and save alot of processing time.
> >
> > anyway to do this with a straight decode?
> >
> > ME>create table xx(y varchar2(20));
> >
> > Table created.
> >
> > ME>insert into xx values('ABCD');
> >
> > 1 row created.
> > ME>commit;
> >
> > Commit complete.
> >
> > ME>select decode(y,'%A%','XXXXX') from xx;
> >
> >
> > DECOD
> > -----
> >
> >
> > 1 row selected.
> >
> > ME>select decode(y,'%A%','XXXXX','BLAH') from xx
> > MASTER_TEST2_at_BOBAIRD>/
> >
> > DECOD
> > -----
> > BLAH
>
>

ahhh.... case statements. I thought I was going to have to do something with nested translates and all that stuff. talk about blowing up my code.

i never saw the 8i docuemtnation for case statements. its exactly the same syntax as 9i right?

thanks. Received on Wed Jun 11 2003 - 21:37:22 CDT

Original text of this message

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