Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda