Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

Part Number E10472-05
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

WHILE LOOP Statement

The WHILE LOOP statement runs one or more statements while a condition is TRUE. The WHILE LOOP statement ends when the condition becomes FALSE or NULL, when a statement inside the loop transfers control outside the loop, or when an exception is raised.

Topics:

Syntax

while_loop_statement ::=

while_loop_statement
Description of the illustration while_loop_statement.gif

See:

Semantics

boolean_expression

This expression is evaluated at the beginning of each iteration of the loop. If its value is TRUE, the statements after LOOP run. Otherwise, control transfers to the statement after the WHILE LOOP statement.

statement

To prevent an infinite loop, at least one statement must change the value of boolean_expression to FALSE or NULL, or transfer control outside the loop. The statements that can transfer control outside the loop are:

label

A label that identifies while_loop_statement (see the syntax diagram statement ::= and the description of label). CONTINUE, EXIT, and GOTO statements can reference this label.

Labels improve readability, especially when LOOP statements are nested, but only if you ensure that the label at the end of the LOOP statement matches one of the labels at the beginning of the same statement (the compiler does not check).

Examples

Related Topics

In this chapter:

In other chapters: