All versions: 3.12 | Development versions: 3.13

WHILE statement

Available in ❌ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

One of the most commonly used loop types is the WHILE statement, which in its procedural form works just like a Java while statement with slightly different syntax.

Procedural dialects may or may not use the LOOP keyword to delimite the loop body, just as with the previous LOOP statement. The jOOQ API always uses it for DSL design reasons. For example, combining the WHILE loop with the variable assignment statement:

-- PL/SQL syntax
WHILE i <= 10 
LOOP
  INSERT INTO t (col) VALUES (i);
END LOOP;
// All dialects
Variable<Integer> i = var("i", INTEGER);
while_(i.le(10)).loop(
  insertInto(T).columns(T.COL).values(i)
)

Notice that while 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: while_().

The jOOQ Logo