Oracle SQL - Oracle "NULL Tips & Tricks"
NULL AND OR
begin
dbms_output.put_line('Oracle "NULL Tips & Tricks"');
dbms_output.put_line('');
if ((NULL and TRUE) is null) then
dbms_output.put_line('NULL and TRUE is NULL');
elsif ((NULL and TRUE) = TRUE) then
dbms_output.put_line('NULL and TRUE is TRUE');
elsif ((NULL and TRUE) = FALSE) then
dbms_output.put_line('NULL and TRUE is FALSE');
end if;
if ((NULL and FALSE) is null) then
dbms_output.put_line('NULL and FALSE is NULL');
elsif ((NULL and FALSE) = TRUE) then
dbms_output.put_line('NULL and FALSE is TRUE');
elsif ((NULL and FALSE) = FALSE) then
dbms_output.put_line('NULL and FALSE is FALSE');
end if;
if ((NULL and NULL) is null) then
dbms_output.put_line('NULL and NULL is NULL');
elsif ((NULL and FALSE) = TRUE) then
dbms_output.put_line('NULL and NULL is TRUE');
elsif ((NULL and FALSE) = FALSE) then
dbms_output.put_line('NULL and NULL is FALSE');
end if;
dbms_output.put_line('');
if ((NULL or TRUE) is null) then
dbms_output.put_line('NULL or TRUE is NULL');
elsif ((NULL or TRUE) = TRUE) then
dbms_output.put_line('NULL or TRUE is TRUE');
elsif ((NULL or TRUE) = FALSE) then
dbms_output.put_line('NULL or TRUE is FALSE');
end if;
if ((NULL or FALSE) is null) then
dbms_output.put_line('NULL or FALSE is NULL');
elsif ((NULL or FALSE) = TRUE) then
dbms_output.put_line('NULL or FALSE is TRUE');
elsif ((NULL or FALSE) = FALSE) then
dbms_output.put_line('NULL or FALSE is FALSE');
end if;
if ((NULL or NULL) is null) then
dbms_output.put_line('NULL or NULL is NULL');
elsif ((NULL or NULL) = TRUE) then
dbms_output.put_line('NULL or NULL is TRUE');
elsif ((NULL or NULL) = FALSE) then
dbms_output.put_line('NULL or NULL is FALSE');
end if;
end;
PL/SQL script returns:
Oracle "NULL Tips & Tricks" NULL and TRUE is NULL NULL and FALSE is FALSE NULL and NULL is NULL NULL or TRUE is TRUE NULL or FALSE is NULL NULL or NULL is NULL
2010.03.28 11:48:36.