CONTINUE is a loop-control statement available in procedural SQL dialects such as PL/pgSQL, T-SQL, and Oracle PL/SQL. When the statement executes, any subsequent commands in the current iteration are bypassed and control jumps to the loop’s condition check (or directly to the top, depending on loop type). This lets you ignore certain rows or situations without breaking out of the loop entirely. Optionally, you can supply a label to identify which surrounding loop to continue when loops are nested. CONTINUE can only appear inside looping constructs (LOOP, WHILE, FOR, FOREACH). Attempting to use it outside a loop or inside a function that does not support procedural flow raises an error.
label_name
(identifier) - Optional. Name of an enclosing loop to target when loops are nested. If omitted, the innermost loop is used.EXIT, BREAK, LOOP, WHILE, FOR, ITERATE, RETURN
PostgreSQL 8.4 (PL/pgSQL)
CONTINUE moves immediately to the next loop iteration, while EXIT terminates the loop and proceeds with the first statement after the loop.
Yes. If no label is supplied, CONTINUE affects the innermost loop that encloses it.
No. Any changes executed before CONTINUE remain committed to the transaction unless you explicitly roll them back.
The database raises a syntax error because CONTINUE is only valid inside looping constructs.