Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SPL Statements >

CONTINUE

Use the CONTINUE statement to start the next iteration of the innermost FOR, WHILE, or FOREACH loop.

Syntax

Read syntax diagramSkip visual syntax diagram>>-CONTINUE--+-FOR-----+--;------------------------------------><
             +-WHILE---+
             '-FOREACH-'
 

Usage

When control of execution passes to a CONTINUE statement, the SPL routine skips the rest of the statements in the innermost loop of the indicated type. Execution continues at the top of the loop with the next iteration.

In the following example, the loop_skip function inserts values 3 through 15 into the table testtable. The function also returns values 3 through 9 and 13 through 15 in the process. The function does not return the value 11 because it encounters the CONTINUE FOR statement. The CONTINUE FOR statement causes the function to skip the RETURN WITH RESUME statement:

CREATE FUNCTION loop_skip()
   RETURNING INT;
   DEFINE i INT;
   ...
   FOR i IN (3 TO 15 STEP 2)
      INSERT INTO testtable values(i, null, null); 
      IF i = 11
         CONTINUE FOR;
      END IF;
      RETURN i WITH RESUME;
   END FOR;

END FUNCTION;

Just as with EXIT (EXIT), the FOR, WHILE, or FOREACH keyword must immediately follow CONTINUE to specify the type of loop. The CONTINUE statement generates errors if it cannot find the specified loop.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]