Oracle PL/SQL - Changing Evaluation Order of Logical Operators

Introduction

The third and first invocation are logically equivalent.

The parentheses in the third invocation only improve readability.

The parentheses in the second invocation change the order of operation.

Demo

SQL>
SQL>--  www . j a  v a 2 s  .  c  o  m
SQL>
SQL> DECLARE
  2    x  BOOLEAN := FALSE;
  3    y  BOOLEAN := FALSE;
  4
  5  BEGIN
  6    print_boolean ('NOT x AND y', NOT x AND y);
  7    print_boolean ('NOT (x AND y)', NOT (x AND y));
  8    print_boolean ('(NOT x) AND y', (NOT x) AND y);
  9  END;
 10  /
NOT x AND y = FALSE
NOT (x AND y) = TRUE
(NOT x) AND y = FALSE

PL/SQL procedure successfully completed.

SQL>
SQL>

Related Topic