Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
CONTINUE statement
Supported by ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A safer way to jump to labels than via GOTO is to use EXIT (jumping out of a LOOP, or block, or other statement) or CONTINUE (skipping a LOOP iteration).
Just like Java's continue, the CONTINUE statement skips the rest of the current iteration in a loop and continues the next iteration. Some dialects use the ITERATE statement for this.
Without a label
-- PL/SQL LOOP i := i + 1; CONTINUE WHEN i <= 10; END LOOP;
// All dialects loop( i.set(i.plus(1)), continueWhen(i.gt(10)) )
With a label
-- PL/SQL <<label>> LOOP i := i + 1; CONTINUE label WHEN i <= 10; END LOOP;
// All dialects
Label label = label("label");
label.label(loop(
i.set(i.plus(1)),
continue(label).when(i.le(10))
))
Notice that continue is a reserved keyword in the Java language, so the jOOQ API cannot use it as a method name. We've suffixed such conflicts with an underscore: continue_().
Dialect support
This example using jOOQ:
loop(i.set(i.plus(1)), continueWhen(i.gt(10)))
Translates to the following dialect specific expressions:
Aurora Postgres, CockroachDB, Oracle, Postgres, YugabyteDB
LOOP i := (i + 1); CONTINUE WHEN i > 10; END LOOP
BigQuery
LOOP
SET i = (i + 1);
IF i > 10 THEN
CONTINUE;
END IF;
END LOOP
DB2, HSQLDB, MariaDB, MySQL, Trino
alias_1:
LOOP
SET i = (i + 1);
IF i > 10 THEN
ITERATE alias_1;
END IF;
END LOOP
H2
for (;;) {
i = (i + 1);
if (i > 10) {
continue;
}
}
Hana
WHILE 1 = 1 DO
i = (i + 1);
IF i > 10 THEN
CONTINUE;
END IF;
END WHILE
Informix
LOOP
LET i = (i + 1);
IF i > 10 THEN
CONTINUE;
END IF;
END LOOP
Snowflake
LOOP
i := (:i + 1);
IF (:i > 10) THEN
CONTINUE;
END IF;
END LOOP
SQLDataWarehouse, SQLServer
WHILE 1 = 1 BEGIN
SET @i = (@i + 1);
IF @i > 10
CONTINUE;
END
ASE, Access, Aurora MySQL, ClickHouse, Databricks, DuckDB, Exasol, Firebird, MemSQL, Redshift, SQLite, Spanner, Sybase, Teradata, Vertica
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!