Saturday, October 22, 2011

Logical comparison of NULL = NULL And NULL != NULL in (SQL) oracle database is false ?

see the example


C:\Documents and Settings\Administrator>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sat Oct 22 13:15:50 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

SQL>
SQL>
SQL>
SQL> conn sys@orcl105 as sysdba
Enter password:
Connected.
SQL>
SQL>
SQL> set serveroutput on
SQL>
SQL> begin
2 if null = null then dbms_output.put_line('TRUE');
3 elsif not (null = null) then dbms_output.put_line('FALSE');
4 else dbms_output.put_line('Not TRUE and not FALSE');
5 end if;
6 end;
7 /

Not TRUE and not FALSE

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

1 begin
2 if null != null then dbms_output.put_line('TRUE');
3 elsif not (null != null) then dbms_output.put_line('FALSE');
4 else dbms_output.put_line('Not TRUE and not FALSE');
5 end if;
6* end;
SQL> /

Not TRUE and not FALSE

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
SQL>

see the following link
https://forums.oracle.com/forums/thread.jspa?messageID=4098609

1 comment:

venusian said...

http://martian36.tistory.com/631

I'm sorry your comment was deleted temporarily because when the comment is written only in English, it is deleted automatically. I found today it was stored in depository, and restored.

Thanks for the reply.