|The jOOQ User Manual. Multiple Pages : SQL building : Procedural statements : EXECUTE statement||previous : next|
All versions: 3.12 | Development versions: 3.13
Available in ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Many dialects support some way of running dynamic SQL from procedural code. For this, the
EXECUTE IMMEDIATE statements can be used.
In some dialects (e.g. Oracle PL/SQL), using
EXECUTE is the only way to run DDL from procedural code.
-- PL/SQL BEGIN EXECUTE IMMEDIATE 'CREATE TABLE t (col int)'; END;
// All dialects create.begin( execute(createTable("t").column("col", INTEGER).getSQL()) ).excute();
You could obviously just pass an arbitrary string to the
EXECUTE statement, as in PL/SQL, but the above example shows how to use this approach also with dynamically created jOOQ statements, by calling Query.getSQL().
This statement is not yet widely supported in jOOQ 3.12+.