Expressing UPDATE statements
In this section, we will express different kinds of updates, including UPDATE ... SET
, UPDATE ... FROM
, and UPDATE ... RETURNING
, and update using row value expressions via the jOOQ DSL syntax. At the time of writing, jOOQ supports updates against a single table, while updates against multiple tables represent a work in progress task.
Expressing UPDATE ... SET
The straightforward UPDATE ... SET
statement can be expressed in jOOQ via the set(field, value)
method, as in the following example (don't forget to call execute()
to trigger the update):
ctx.update(OFFICE) .set(OFFICE.CITY, "Banesti") .set(OFFICE.COUNTRY, "Romania") .where(OFFICE.OFFICE_CODE.eq("1")) .execute();
The rendered SQL for MySQL dialect will be as follows:
UPDATE `classicmodels`.`office` SET `classicmodels`.`office'.`city` = ?, `classicmodels...