O'Reilly logo

Oracle PL/SQL Programming, 5th Edition by Bill Pribyl, Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Iterative Processing with Loops

This chapter explores the iterative control structures of PL/SQL, otherwise known as loops, which let you execute the same code repeatedly. It also describes the CONTINUE statement, introduced for loops in Oracle Database 11g. PL/SQL provides three different kinds of loop constructs:

  • The simple or infinite loop

  • The FOR loop (numeric and cursor)

  • The WHILE loop

Each type of loop is designed for a specific purpose with its own nuances, rules for use, and guidelines for high-quality construction. As I explain each loop, I’ll provide a table describing the following properties of the loop:

Property

Description

How the loop is terminated

A loop executes code repetitively. How do you make the loop stop executing its body?

When the test for termination takes place

Does the test for termination take place at the beginning or end of the loop? What are the consequences?

Reason to use this loop

What are the special factors you should consider to determine if this loop is right for your situation?

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required