Oracle PL/SQL - PL SQL Operator BOOLEAN Comparisons

Introduction

By definition, TRUE is greater than FALSE. Any comparison with NULL returns NULL.

Demo

SQL>
SQL> CREATE OR REPLACE PROCEDURE print_boolean (
  2    b_name   VARCHAR2,-- from   w ww  . ja va2s .co m
  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> BEGIN
  2    print_boolean ('TRUE > TRUE', TRUE > TRUE);
  3    print_boolean ('TRUE > FALSE', TRUE > FALSE);
  4    print_boolean ('TRUE > NULL', TRUE > NULL);
  5
  6  END;
  7  /
TRUE > TRUE = FALSE
TRUE > FALSE = TRUE
TRUE > NULL = NULL

PL/SQL procedure successfully completed.

SQL>

Related Topic