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: NULL v. null string

Re: NULL v. null string

From: Gerrit-Jan Linker <gjlinker_at_oraxcel.com>
Date: Sat, 14 Jul 2001 21:19:25 +0100
Message-ID: <9iq9ca$7tp$1@plutonium.btinternet.com>

I always remember this behavior by thinking what null actually means. NULL is an indication that no value is specified. A null string '' specifies an empty string, which is a definite value.

Now when comparing values you cannot say anything sensible when one of the values is NULL (unspecified). It would be great if boolean logic would have Yes/No/Don't Know as values. Or perhaps that would just be even more confusing. Anyhow these comparisons will render:

Null = '' is False (meaning Don't Know) Null = Null is False (meaning Don't Know; comparing 2 unknowns, how can they ever be equal?)

'' = Null        is False (meaning Don't Know)
'' = ''     True    (you specified 2 values, and yes both of the values are
empty strings)

Hope this did not confuse you even more...

--
Gerrit-Jan Linker
SQL*XL: addin for Excel for easy access to Oracle databases
http://www.oraxcel.com


"Chuck Hamilton" <chuck_hamilton_at_yahoo.com> wrote in message
news:1hvtkt0ggngfnendsgejsodpko3d2e04l5_at_4ax.com...

> If NULL is not the same as a null string, then why does this block of
> code display 'YES'.
>
> begin
> if '' is null then
> dbms_output.put_line('yes');
> else
> dbms_output.put_Line('no');
> end if;
> end;
>
> Same this with this. If null string is a known value and NULL is an
> unknown value, why does this display no?
>
> begin
> if '' = '' then
> dbms_output.put_line('yes');
> else
> dbms_output.put_Line('no');
> end if;
> end;
> --
> Chuck Hamilton
> chuck_hamilton_at_yahoo.com
>
> "Do not be deceived, God is not mocked;
> for whatever a man sows, this he will also
> reap." (Gal 6:7 NASB)
Received on Sat Jul 14 2001 - 15:19:25 CDT

Original text of this message

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