|The jOOQ User Manual. Multiple Pages : SQL building : Procedural statements : LOOP statement||previous : next|
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Many procedural languages support a condition-less loop, which in its pure form, just loops forever. In order to create an infinite number of records in a table, one might write the following:
-- PL/SQL syntax LOOP INSERT INTO t (col) VALUES (1); END LOOP;
// All dialects loop( insertInto(T).columns(T.COL).values(1) )
Not all dialects support this syntax due to the inherent risks of infinite loops it imposes. But jOOQ can easily emulate this for you, should you have good reasons for this syntax. For example, in T-SQL:
-- T-SQL WHILE 1 = 1 BEGIN INSERT INTO t (col) VALUES (1); END;
An "infinite" loop is usually exited using an EXIT statement.