Cursor FOR loop v15
The programming logic required to process the result set of a cursor usually includes a statement to open the cursor, a loop construct to retrieve each row of the result set, a test for the end of the result set, and a statement to close the cursor. The cursor FOR loop is a loop construct that eliminates the need to individually code these statements.
The cursor FOR
loop opens a previously declared cursor, fetches all rows in the cursor result set, and then closes the cursor.
The syntax for creating a cursor FOR
loop is as follows:
Where:
record
is an identifier assigned to an implicitly declared record with definition cursor%ROWTYPE
.
cursor
is the name of a previously declared cursor.
statements
are one or more SPL statements. There must be at least one statement.
This example uses a cursor FOR
loop:
The following is the output from this procedure: