Skip to content

CONTINUE

CONTINUE skips the remaining statements in the current iteration of a loop and begins the next iteration.

CONTINUE is only valid within a scripting block.

See also BREAK.

Syntax

sql
CONTINUE [label];

or

ITERATE [label];

Arguments

label (optional): When a label is specified, CONTINUE begins execution at the first statement of the loop with that label. This allows breaking out of more than one level of a nested loop or nested branching structure.

Usage Notes

If the loop is nested within one or more other loops, it is possible to skip to the first statement of the outer loop. To do this, add the label of the outer loop as part of the CONTINUE statement.

Example 1 | CONTINUE

The following loop runs five times. Since the code after the CONTINUE statement is not executed, the variable named count2 will have the value 0 instead of 3.

sql
DECLARE
  count1 INTEGER;
  count2 INTEGER;
BEGIN
  count1 := 0;
  count2 := 0;
  WHILE (count1 < 5) DO
    count1 := count1 + 1;
    CONTINUE;
    count2 := count2 + 1;
  END WHILE;
  select :count2 as count2, :count1 as count1;
END;
+--------+--------+
| count2 | count1 |
+--------+--------+
| 0      | 5      |
+--------+--------+