Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: NULL v. null string
the empty string '' is the same as NULL
but the = comparison does not work with NULL
it will always return no if NULL
is compared with any other value or NULL
therefor you have to use "is" if you have to compare a null
true:
'' is null
'' is ''
null is null
false:
'' = null
'' = ''
null = null
Chuck Hamilton wrote:
> 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 21 2001 - 16:36:03 CDT
![]() |
![]() |