Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
JOOQ - Update Statement with Expression

In PostgreSQL you can use an expression which is able to make use of the column values for the given row to define the value in the set statement i.e

UPDATE some_table
SET col_a = (col_b != 1)
WHERE col_c = 'some val'

Is there a way to do this in JOOQ? - I've looked through the JOOQ documentation, but I can't see any reference to it

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I'm assuming col_a is a Field<Boolean>, in case of which, you can wrap a Condition in a Field<Boolean> expression using DSL.field(Condition)

// As always, assuming you have this static import:
import static org.jooq.impl.DSL.*;

ctx.update(SOME_TABLE)
   .set(SOME_TABLE.COL_A, field(SOME_TABLE.COL_B.ne(1)))
   .where(SOME_TABLE.COL_C.eq("some val"))
   .execute();
over 4 years ago · Santiago Trujillo Report

0

Following https://www.jooq.org/doc/3.13/manual/sql-building/sql-statements/update-statement/#N6ABB6, I think you would do

update(SOME_TABLE)
.set(row(SOME_TABLE.A),
     row(SOME_TABLE.B.neg()))
.where(SOME_TABLE.C.eq("some val"));
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!