Introduction

NOT returns the opposite of its operand, unless the operand is NULL.

NOT NULL returns NULL, because NULL is an indeterminate value.

Demo

SQL>
SQL>-- from   w w w  . j a  va2  s.co m
SQL> CREATE OR REPLACE PROCEDURE print_boolean (
  2    b_name   VARCHAR2,
  3    b_value  BOOLEAN
  4   ) IS
  5  BEGIN
  6    IF b_value IS NULL THEN
  7      DBMS_OUTPUT.PUT_LINE (b_name || ' = NULL');
  8    ELSIF b_value = TRUE THEN
  9      DBMS_OUTPUT.PUT_LINE (b_name || ' = TRUE');
 10    ELSE
 11      DBMS_OUTPUT.PUT_LINE (b_name || ' = FALSE');
 12    END IF;
 13  END;
 14  /

Procedure created.

SQL>
SQL>
SQL> DECLARE
  2    PROCEDURE print_not_x (
  3      x  BOOLEAN
  4    ) IS
  5    BEGIN
  6      print_boolean ('x', x);
  7      print_boolean ('NOT x', NOT x);
  8    END print_not_x;
  9
 10  BEGIN
 11    print_not_x (TRUE);
 12    print_not_x (FALSE);
 13    print_not_x (NULL);
 14  END;
 15  /
x = TRUE
NOT x = FALSE
x = FALSE
NOT x = TRUE
x = NULL
NOT x = NULL

PL/SQL procedure successfully completed.

SQL>

Related Topic