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: Andy Hardy <aph_at_ahardy.demon.co.uk>
Date: Thu, 24 Dec 1998 20:41:38 GMT
Message-ID: <01be2ed2$b33bc080$LocalHost@viao1.camk.com>


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 Thu Dec 24 1998 - 14:41:38 CST

Original text of this message

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