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: Alan Black <alan_at_opcomp.demon.co.uk>
Date: Fri, 25 Dec 1998 20:28:19 +0000
Message-ID: <Yko2zDAjV$g2EwwV@opcomp.demon.co.uk>


Andy,

Tried this, didn't work, Oracle says it can only be used as part of DML.

Alan.

In article <01be2ed2$b33bc080$LocalHost_at_viao1.camk.com>, Andy Hardy <aph_at_ahardy.demon.co.uk> writes
>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
>>

--
Alan Black Received on Fri Dec 25 1998 - 14:28:19 CST

Original text of this message

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