Lab 8.1 Simple Loops

Lab Objectives

After this Lab, you will be able to:

Use Simple Loops with EXIT Conditions

Use Simple Loops with EXIT WHEN Conditions

A simple loop, as you can see from its name, is the most basic kind of loop and has the following structure:

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

The reserved word LOOP marks the beginning of the simple loop. Statements 1 through N are a sequence of statements that is executed repeatedly. These statements consist of one or more of the standard programming structures. END LOOP is a reserved phrase that indicates the end of the loop construct.

The flow of logic from this structure is illustrated in Figure 8.1.

Figure 8.1. Simple Loop

Every time the loop is iterated, ...

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.