Oracle PL/SQL - PL SQL Operator BOOLEAN Expressions

Introduction

A BOOLEAN expression is an expression that returns a BOOLEAN value-TRUE, FALSE, or NULL.

The simplest BOOLEAN expression is a BOOLEAN literal, constant, or variable.

The following are BOOLEAN expressions:

  • NOT boolean_expression
  • boolean_expression relational_operator boolean_expression
  • boolean_expression { AND | OR } boolean_expression

You use BOOLEAN expressions as conditions in control statements and in SQL WHERE clauses.

You can use a BOOLEAN variable itself as a condition.

In the following code, the conditions in the loops are equivalent.

Demo

SQL>
SQL> DECLARE-- ww  w. jav a2  s  .co m
  2    done BOOLEAN;
  3  BEGIN
  4    -- These WHILE loops are equivalent
  5
  6    done := FALSE;
  7    WHILE done = FALSE
  8      LOOP
  9        done := TRUE;
 10      END LOOP;
 11
 12    done := FALSE;
 13    WHILE NOT (done = TRUE)
 14      LOOP
 15        done := TRUE;
 16      END LOOP;
 17
 18    done := FALSE;
 19    WHILE NOT done
 20      LOOP
 21        done := TRUE;
 22      END LOOP;
 23  END;
 24  /

PL/SQL procedure successfully completed.

SQL>

Related Topic