Friday, March 09, 2012

Boolean Variables in PL/SQL

You can declare Boolean variables in PL/SQL like this:

SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2  DONE BOOLEAN := FALSE;
  3  COUNTER NUMBER := 0;
  4  BEGIN
  5  WHILE NOT DONE LOOP
  6  COUNTER := COUNTER + 1;
  7  DONE := (COUNTER > 9);
  8  END LOOP;
  9  DBMS_OUTPUT.PUT_LINE('Counter = '||COUNTER);
10  END;
11  /
Counter = 10

PL/SQL procedure successfully completed.

SQL>

No comments:

Post a Comment