Re: if-then-else expression in SELECT list

From: V. Scott Anders <vscotta_at_primenet.com>
Date: 1996/08/08
Message-ID: <4ued9n$qeq_at_nnrp1.news.primenet.com>#1/1


Bill Duttweiler <billd_at_slb.com> wrote:

>Using ACCESS/ODBC/JET I can use the 'iif()'
>function in a SELECT list to do an if-then-else
>test. I've tried using the ORACLE DECODE()
>expression, but it doesn't allow conditions. For
>example,
 

>DECODE(A = B, TRUE, <true reuslt>, <false result>)
 

>gives an error like "missing right parenthesis".
>It just doesn't appear that DECODE() can handle
>condition expressions.
 

>Is there any way to do an if-then-else expression?
 

>Thanks.
 

>Bill

Bill,

The decode statement is very powerful. Not only can it handle conditional expressions, it can also be nested for grouping purposes. Yes, it's not as easy to follow as an if-then statement, but it does the same job.

Your statement should read:

        DECODE(A, B, <true result>, <default result>)

It is the expression "A = B" that is giving you the error.

I hope this helps.

Scott Anders
Phoenix, AZ Received on Thu Aug 08 1996 - 00:00:00 CEST

Original text of this message