DECLARE
x BOOLEAN;
y BOOLEAN;
PROCEDURE show_truth (str IN VARCHAR2, val IN BOOLEAN)
IS
BEGIN
DBMS_OUTPUT.put_line (
str
|| ' - '
|| CASE val
WHEN TRUE THEN 'TRUE'
WHEN FALSE THEN 'FALSE'
ELSE 'NULL'
END);
END;
PROCEDURE show_line (x_in IN BOOLEAN, y_in IN BOOLEAN)
IS
BEGIN
show_truth ('x and y', x_in AND y_in);
show_truth ('x or y', x_in OR y_in);
show_truth ('not x', NOT x_in);
DBMS_OUTPUT.put_line ('---------------');
END;
BEGIN
show_line (TRUE, TRUE);
show_line (TRUE, FALSE);
show_line (TRUE, NULL);
--
show_line (FALSE, TRUE);
show_line (FALSE, FALSE);
show_line (FALSE, NULL);
--
show_line (NULL, TRUE);
show_line (NULL, FALSE);
show_line (NULL, NULL);
END;
x and y - TRUE
x or y - TRUE
not x - FALSE
---------------
x and y - FALSE
x or y - TRUE
not x - FALSE
---------------
x and y - NULL
x or y - TRUE
not x - FALSE
---------------
x and y - FALSE
x or y - TRUE
not x - TRUE
---------------
x and y - FALSE
x or y - FALSE
not x - TRUE
---------------
x and y - FALSE
x or y - NULL
not x - TRUE
---------------
x and y - NULL
x or y - TRUE
not x - NULL
---------------
x and y - FALSE
x or y - NULL
not x - NULL
---------------
x and y - NULL
x or y - NULL
not x - NULL
---------------