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: Please Help on Decode statement

Re: Please Help on Decode statement

From: Matthias Gresz <GreMa_at_t-online.de>
Date: 1997/11/12
Message-ID: <64bo7k$juu$1@news02.btx.dtag.de>#1/1

Peter Schneider wrote:
>
> On Tue, 11 Nov 1997 22:07:18 -0000, "Mujahid Hamid"
> <mujahid_at_pharmco.demon.co.uk> wrote:
>
> >I am a new PL/Sql Programmer (Oracle 7.3)
> >
> >I am trying to use decode as following but it does not work; I trying to
> >avoid using a complex 'if then else' statement by the use of decode:
> >
> >v_new_value:=decode(v_name,'one',1,'two',2,'0')
> >
> >the error message I get is : you must use decode within sql.
> >
> >If I use decode with a select then it works eg:
> >
> >select decode(v_name,'one'1,'two,2) from table
> >
> >help me please
> >
> >Cheers.
> >
>
> Hi Mujahid,
>
> using decode with the dual table will do what you want:
> select decode(v_name,'one'1,'two,2) from dual
>
> HTH,
> Peter
>
> Peter Schneider
> pschneider.ctj_at_metronet.de

Hi Mujahid,

select decode(v_name,'one'1,'two,2) into v_new_value from dual;

will do your job.

-- 
Regards

Matthias Gresz    :-)
Received on Wed Nov 12 1997 - 00:00:00 CST

Original text of this message

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