User's Guide
Part VI. SQL Anywhere Reference
Chapter 43. Watcom-SQL StatementsContinue execution by leaving a compound statement or LOOP.
LEAVE statement-label
Procedures, triggers, and batches.
None.
None.
The LEAVE statement is a control statement that allows you to leave a labeled compound statement or a labelled loop. Execution resumes at the first statement after the compound statement or loop.
The compound statement that is the body of a procedure or triggers has an implicit label that is the same as the name of the procedure or trigger.
The following fragment shows how the LEAVE statement is used to leave a loop.
SET i = 1;lbl:LOOPINSERTINTO Counters ( number )VALUES ( i ) ;IF i >= 10 THENLEAVE lbl ;END IF ;SET i = i + 1END LOOP lbl
The following example fragment uses LEAVE in a nested loop.
outer_loop:LOOPSET i = 1;inner_loop:LOOP...SET i = i + 1;IF i >= 10 THENLEAVE outer_loopEND IFEND LOOP inner_loopEND LOOP outer_loop