The LOOP LIMIT pragma enables you to limit the number of loop passes in a routine.
The LOOP LIMIT pragma is effective ahead of the SQL statement CALL and ahead of other DML statements. When specified ahead of DML statements, the pragma has an effect on all User Defined Functions (UDFs) and the routines of the DML statement these contain. When placed ahead of SQL statements, the pragma has no effect in a routine.
LOOP LIMIT
unsigned_integer
unsigned_integer
Specifies the maximum number of passes for a loop.
When unsigned_integer=0, the number of loop passes is unlimited.
unsigned_integer=0 is also the default value when the pragma is not specified.
When this pragma is specified, the loop body is canceled after the specified number of passes has been executed for each called loop of the routine concerned, and an SQLSTATE is reported. This enables endless loops to be avoided.