1 – beginning-label:
Assigns a name to a control loop. A beginning label used with the LEAVE statement lets you perform a controlled exit from the WHILE loop. If you include an ending label, it must be identical to its corresponding beginning label. A beginning label must be unique within the procedure containing the label.
2 – compound-use-statement
Identifies the SQL statements allowed in a compound statement block. See the Compound Statement for the list of valid statements.
3 – DO
Marks the start of a control loop.
4 – END LOOP ending-label
Marks the end of a LOOP control 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 ending-label argument makes multistatement procedures easier to read, especially in very complex multistatement procedure blocks.
5 – END WHILE ending-label
Marks the end of a DO control 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 ending-label argument makes multistatement procedures easier to read, especially in very complex multistatement procedure blocks.
6 – LOOP
Marks the start of a control loop.
7 – WHILE predicate
Specifies a search condition that controls how many times SQL can execute a compound statement. SQL evaluates the WHILE search condition. If it evaluates to TRUE, SQL executes the associated sequence of SQL statements. If SQL does not encounter an error exception, control returns to the WHILE clause at the top of the loop for subsequent evaluation. Each time the search condition evaluates to TRUE, the WHILE- DO statement executes the SQL statements embedded within its DO . . . END WHILE block. If the search condition evaluates to FALSE or UNKNOWN, SQL bypasses the DO . . . END WHILE block and passes control to the next statement.