Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: NULL v. null string
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 areempty 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...Received on Sat Jul 14 2001 - 15:19:25 CDT
> 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)
![]() |
![]() |