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: Performance: If...Then...Else vs Decode

Re: Performance: If...Then...Else vs Decode

From: Maciej Zoltowski <mzoltowski_at_eragsm.com.pl>
Date: Mon, 28 Dec 1998 09:33:33 +0100
Message-ID: <3687425D.94B528FF@eragsm.com.pl>


No.
PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL statement only.

Andy Hardy wrote:
>
> I don't know about the performance issues, but you should be able to use
> decode like:
>
> var_a := decode(code_a, 'C', 'CAT', 'D','DOG' etc
>
> without the dummy call to dual
>
> Andy
>
> Alan Black <alan_at_opcomp.demon.co.uk> wrote in article
> <lr1BjAAnTUg2EwHE_at_opcomp.demon.co.uk>...
> > I want to decode the value of a column within an Insert Trigger to
> > provide a description.
> >
> > Setting aside any data redundancy issues...
> >
> > If I want to use Decode, I have to do something like this...
> >
> > select Decode(:new.MyCode, 'C', 'Cat',
> > 'D', 'Dog',
> > 'P', Parrot',
> > 'E', 'Elephant', NULL)
> > into :new.MyDescription
> > from Dual;
> >
> > Not only does this mean that I am making a function call, but also
> > issuing a DML statement.
> >
> > How inefficient is this, bearing mind that the code will be called many
> > times, in comparison to the more verbose method of...
> >
> > if :new.MyCode = 'C' then
> > :new.MyDescription := 'Cat';
> > else if :new.MyCode = 'D' then
> > :new.MyDescription := 'Dog';
> > ...
> > else
> > :new.MyDescription := NULL;
> > end if;
> >
> > --
> > Alan
> >
Received on Mon Dec 28 1998 - 02:33:33 CST

Original text of this message

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