1 – AS EACH ROW OF cursor
Creates a result table with a specified cursor. The optional naming of a cursor lets you use positioned data manipulation language statements in the DO clause of a FOR loop.
2 – AS EACH ROW OF select expr
Creates a simple result table. After SQL creates the result table from the select expression, the DO clause executes a set of SQL statements (compound-use- statement) for each result table row.
3 – beginning-label:
Assigns a name to the FOR statement. A named FOR loop is called a labeled FOR loop statement. If you include an ending label, it must be identical to its corresponding beginning label. A beginning label must be unique within the procedure in which the label is contained.
4 – DO
Executes a block of SQL statements for each row of the select expression result table.
5 – END_FOR
Marks the end of a FOR loop. If you choose to include the optional ending label, it must match exactly its corresponding beginning label. An ending label must be unique within the procedure in which the label is contained. The optional end-label argument makes the FOR loops of multistatement procedures easier to read, especially in very complex procedure blocks.
6 – FOR variable name
Specifies a name for a record consisting of a field for each named column of the FOR loop select expression. Each field in the record contains the data represented by each column name in each row of the select expression result table. The variable name lets you reference a field in the compound-use- statement argument, for example: variable-name.column-name.