From the course: Oracle Database 19c: PL/SQL

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Programming contstructs: FOR loop

Programming contstructs: FOR loop - Oracle Database Tutorial

From the course: Oracle Database 19c: PL/SQL

Programming contstructs: FOR loop

- It's not hyperbole to say that without for loops in PL/SQL it wouldn't be very procedural. Looping through all the elements of a memory array or looping through all the rows of a row set is going to happen in almost every PL/PL/SQL procedure. What is a for loop? It's a set of statements in PL/SQL starting with a FOR and LOOP keywords, ending with the keywords END LOOP and it iterates through a sequence of integers in either ascending or descending order. You've likely seen a for loop equivalent in other programming languages. Oracle PL/SQL does all of that and more. Here's the syntax for the for loop in a PL/SQL block. Only a couple other keywords are optional. As you iterate through the values from lower bound to upper bound, index is a local variable which you don't have to define that holds successive values. After iterating through the loop from lower bound to upper bound, the loop exits. Between loop and end loop…

Contents