MarthinusSwart.com

PL/SQL For Loops.

To declare for loops in PL/SQL is very straight forward once you know the keywords and syntax.
To declare a for loop, to loop through a cursor, first declare the cursor:

CURSOR my_cursor IS SELECT mySchema.myTable.* FROM mySchema.myTable;

After the cursor is declared you just need to declare a record variable:

myTable_record myTable%ROWTYPE;

The %ROWTYPE keyword is a nice PL/SQL short hand to initialise a variable with the characteristics of a row in the desired table.
We are now ready to use our cursor and the record variable in our For Loop:

FOR myTable_record IN my_cursor LOOP
BEGIN
...
END