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: DECODE and boolean-expression

Re: DECODE and boolean-expression

From: Alexander Mueller <millerax_at_hotmail.com>
Date: Wed, 25 Jan 2006 09:37:59 +0100
Message-ID: <43d738e9$0$20784$9b4e6d93@newsread4.arcor-online.net>


Mark C. Stock schrieb:

> "Alexander Mueller" <millerax_at_hotmail.com> wrote:

>> how can i use Decode if I want to evaluate an boolean expression?
>> I want to convert an Access-SQL-Statement using IIF:
>>
>> IIf (Val > 100, ID, 9999) As ID
>>
>> How can I check if Val is bigger then 100 with Decode,
>> my pseudo code looks like:
>>
>> Decode (Val > 100, true, ID, 9999) As ID
>>
>> but what's the equivalent for 'true' in PL/SQL?
>>
>> Mfg,
>> Alex

> 
> CASE expression (depending on your DB version)
> 
> otherwise, use a DECODE on a SIGN expression (returns -1, 0, or 1 and can be 
> used to kludge if-then-else logic)

Hi Mark

We have 8i, I think that is pre-CASE, but SIGN does work. I noticed that SIGN doesn't accept expression using '>' or '<', like SIGN (INT_VALUE < 0), but instead of writing column_name < 100 one can also write column_name - 100 and test if it is bigger 0 so i can change the code now using DECODE with SIGN Thanks for your response, helps me to fix a lot code.

Mfg,
Alex Received on Wed Jan 25 2006 - 02:37:59 CST

Original text of this message

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