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

Home -> Community -> Usenet -> c.d.o.misc -> Re: where something IN decode

Re: where something IN decode

From: Ed prochak <ed.prochak_at_alltel.com>
Date: 23 Jan 2002 05:13:24 -0800
Message-ID: <e51b160.0201230513.4d9ac0bc@posting.google.com>


zzesers2002_at_yahoo.com (Zzesers) wrote in message news:<99584c0b.0201221337.1cb9dcd3_at_posting.google.com>...
> DStevens <dstevens_at_navidec.com> wrote in message news:<a2k12j$8ju$2_at_newsreader.mailgate.org>...
> > select * from dual where 0 in (decode(0,0,1));
> >
> >
> > >
>
>
> Thanks DStevens, but what I need is a decode statement that allows me
> to have a set of numbers for the in statement. Something that would
> be akin to:
>
> If the decode is true:
>
> select * from dual where 0 in (0,1,2);
>
> otherwise:
>
> select * from dual where 0 in (0);
>
> I'm using hardcoded values for an example, this is part of a far more
> complex SQL query.
>
> Thanks,
> Zzesers

Unfortuantely this isn't PERL, so DECODE cannot return a list. You may have to devise something like this:

select * from xtable

 where xcol in (decode(yvar,0,0,0),
                decode(yvar,0,1,NULL),
                decode(yvar,0,2,NULL)
                );

If the list cannot go in the decode, then the decode must go in the list.

   Ed Prochak Received on Wed Jan 23 2002 - 07:13:24 CST

Original text of this message

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