Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda