Lab 8.3 Numeric for Loops

Lab Objectives

After this Lab, you will be able to:

Use Numeric FOR Loops with the IN Option

Use Numeric FOR Loops with the REVERSE Option

A numeric FOR loop is called numeric because it requires an integer as its terminating value. Its structure is as follows:

FOR loop_counter IN[REVERSE] lower_limit..upper_limit LOOP 
   STATEMENT 1; 
   STATEMENT 2; 
   … 
   STATEMENT N; 
END LOOP; 

The reserved word FOR marks the beginning of a FOR loop construct. The variable, loop_counter, is an implicitly defined index variable. There is no need to define the loop counter in the declaration section of the PL/SQL block. This variable is defined by the loop construct. Lower_limit and upper_limit are two integer numbers that define the number ...

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.