An understanding of null usage in oracle SQL statements recently found some problems with null usage when writing pl/SQL package. The following is my understanding and may be incorrect.
You are welcome to correct. Www.2cto.com SQL> set serveroutput onSQL> begin 2 if null <> 1 then 3 dbms_output.put_line ('aaaaa'); 4 else 5 dbms_output.put_line ('bbbbbb'); 6 end if; 7 end; 8/bbbbbb SQL> begin 2 if not null <> 1 then 3 dbms_output.put_line ('aaaaa'); 4 else 5 dbms_output.put_line ('bbbbbbbb'); 6 end if; 7 end; 8/bbbbbb From the above we can see that when null is compared with the actual value, both = and <> return false, even if the front side is not,
The returned value is also false. Therefore, when writing an SQL statement in the future, if null is used, try to use the is or is not if you are not sure.
Method, even if the code is cumbersome. I don't know whether it is true. please correct me.