The LOOP statement controls looping logic in a compound statement. It provides an unconditional loop that continues until there is an explicit or condition-based (with a carefully designed EXIT or UNDO condition-handler) loop exit. You must therefore be certain to include a LEAVE statement or SIGNAL statement in your design logic. In addition, we recommend that you use the optional DATACOM LOOPLIMIT clause.
Following is the syntax for the LOOP statement:
►►─┬──────────────────────┬─ LOOP ─ proc-SQL-stmt-list ─ END LOOP ────────────► └─ start-label: ───────┘ ►─┬───────────────────┬─┬───────────────────────────────────────┬────────────►◄ └─ end-label; ──────┘ └─ DATACOM LOOPLIMIT ─ integer-literal ─┘
(Optional) A start-label: is an SQL identifier (followed by a colon) that can be used in various flow-control statements to mark the destination of a branch. When you specify an end-label you must also specify a matching start-label. The labels must match.
A proc-SQL-stmt-list is a list of proc-SQL-stmt statements, each terminated by a semicolon. For information about a proc-SQL-stmt, see CREATE PROCEDURE Syntax and Description.
We recommend that you use DATACOM LOOPLIMIT. DATACOM LOOPLIMIT is a CA Datacom extension that we provide to allow your proactive avoidance of endless loops that might be caused by faulty logic, unexpected or missing column values, or other unforeseen conditions. The Multi-User startup option SQL_DATACOM_LOOPLIMIT can be used to force a default limit on each looping statement. An error is produced if the limit is exceeded.
Defines how many loops are too many.
|
Copyright © 2014 CA.
All rights reserved.
|
|