Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Funny comparisions :)

Re: Funny comparisions :)

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 29 Dec 1999 11:16:28 -0500
Message-ID: <smck6s8834a817n9da4g443pe138p6ie1o@4ax.com>


A copy of this was sent to "Michael Ju. Tokarev" <mjt_at_tls.msk.ru> (if that email address didn't require changing) On Wed, 29 Dec 1999 18:28:28 +0300, you wrote:

>Thomas Kyte wrote:
>>
>[]
>> >
>>
>> how about
>>
>> if ( a = b OR (a is null and b is null) )
>> then
>> -- they are "equal"
>> else
>> -- they are not
>> end if;
>>
>
>This is a bit strange for me. Maybe some was changed in recent (or not very so)
>versions? I always thinked that
> a = b is null if a or b is null

sort of correct. "a=b" is UNKNOWN if a and/or b is NULL.

> a or b is also null if a or b is null

it is not NULL, it is unknown (tri-valued logic, values of TRUE, FALSE, UNKNOWN). In the above, if a AND b is NULL, this evaluates to

if ( UNKNOWN or ( TRUE and TRUE ) ) then

and that evaluates to

if ( TRUE ) then

In the above, if A is NULL and B is NOT NULL, this evaluates to

if ( UNKNOWN or ( TRUE and FALSE ) ) then

and that evaluates simply to

if ( FALSE ) then...

>Maybe I was totally wrong... The secons one seemed to be ok (logic!) --
>if b is true, the whole expression should be true whenever a is true/false/null.
>But if b is false, the whole one will be the same as a -- true/false/NULL (i.e.
>if b is false, and a is null, than (a or b) is also null). Right?
>
>If so, then I just "invented a bicycle", sorry for my stupid "solution" for non-existed
>problem... And yes, that is worked (surprise ;)!
>

no problem -- there are typically dozens of ways to solve every problem....

>[]
>>
>> Thomas Kyte tkyte_at_us.oracle.com
>> Oracle Service Industries Reston, VA USA
>>
>
>Thanks!

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Dec 29 1999 - 10:16:28 CST

Original text of this message

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