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>--   w ww  .  j ava  2s  .co 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