Re: DECODE .vs IF THEN ELSE (or ELSIF)

From: Carlos <miotromailcarlos_at_netscape.net>
Date: 30 Mar 2004 23:53:11 -0800
Message-ID: <1de5ebe7.0403302353.775ce498_at_posting.google.com>


Moshe_t_at_yahoo.com (moshe) wrote in message news:<616be6f6.0403300906.34626f35_at_posting.google.com>...
> Hello,
>
> I have simple function that get char value and according its value
> return char value.
> The function can looks like :
> IF (InputValue = '00') THEN RETURN 'xxx'
> ELSIF (InputValue = '01') THEN RETURN 'yyy'
> ELSIF (InputValue = '02') THEN RETURN 'zzz'
> and so on...
>
> Or I can use DECODE like :
> Result := DECODE('00','xxx','01','yyy','02','zzz' .... )
>

NO, YOU CAN'T. DECODE can only be used inside a SQL statement.

> My question is consider only to performance - What is the best way ?
> Where I
> will get the highest performance ?
>
>
> Thanks.

Martin Burbridge is completely right: don't try to outsmart the DB with hand-made functions and let the DB do what it does better.

Regards.

Carlos. Received on Wed Mar 31 2004 - 09:53:11 CEST

Original text of this message