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

Labels

Applies to ❌ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

In imperative languages, labels are essential with simpler cases of loops (e.g. the LOOP statement), with nested loops, or if you must, when using the GOTO statement.

Using jOOQ, you can label any org.jooq.Statement by using DSL.label():

-- PL/SQL
<<label>>
BEGIN NULL; END;
// All dialects
Label label = label("label");
label.label(begin())

That's a lot of labels.

The main usages of these labels will be discussed in the following sections about, EXIT, and CONTINUE

Dialect support

This example using jOOQ:

l.label(loop())

Translates to the following dialect specific expressions:

Aurora Postgres, CockroachDB, Informix, Postgres, YugabyteDB

<<l>>
LOOP
END LOOP

DB2, HSQLDB, MariaDB, MySQL, Trino

l:
LOOP
END LOOP

Firebird

l:
WHILE (1 = 1) DO BEGIN
END

H2

l:
for (;;) {
}

Oracle

<<l>>
LOOP
  NULL;
END LOOP

Snowflake

LOOP
  NULL;
END LOOP l

SQLDataWarehouse, SQLServer

l:
WHILE 1 = 1 BEGIN
  IF 1 = 0 SELECT 1;
END

ASE, Access, Aurora MySQL, BigQuery, ClickHouse, Databricks, Derby, DuckDB, Exasol, Hana, MemSQL, Redshift, SQLite, 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!

The jOOQ Logo