LAB 8.2 WHILE Loops

Lab Objectives

After this Lab, you will be able to:

Use WHILE Loops

A WHILE loop has the following structure:

WHILE CONDITION LOOP 
   STATEMENT 1; 
   STATEMENT 2; 
   … 
   STATEMENT N; 
END LOOP; 

The reserved word WHILE marks the beginning of a loop construct. The word CONDITION is the test condition of the loop that evaluates to TRUE or FALSE. The result of this evaluation determines whether the loop is executed. Statements 1 through N are a sequence of statements that is executed repeatedly. The END LOOP is a reserved phrase that indicates the end of the loop construct.

This flow of the logic is illustrated in Figure 8.3.

Figure 8.3. WHILE Loop

Figure 8.3 shows that the test condition is evaluated prior to each iteration of the ...

Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.