【发布时间】:2021-06-03 14:56:56
【问题描述】:
我想创建一个 PostgreSQL 查询来更新下边界为零的多个列 (SMALLINT)。我正在考虑 Java 方法 Math.max(x,y)。像Math.max(columnValue, 0) 这样的东西。有DSL.greatest(x,y)的方法,看起来很完美。但是,这只接受 Field 对象作为参数。
例如:
dslContext
.update(TABLE)
.set(TABLE.COLUMN1, DSL.greatest(TABLE.COLUMN1.minus(1), (short) 0))
.set(TABLE.COLUMN2, DSL.greatest(TABLE.COLUMN2.minus(1), (short) 0))
... some more
.where(TABLE.ID.eq(tableId))
.execute();
这会导致零处的编译错误。 是否可以从数字中创建 Field 对象?或者我怎样才能以其他方式实现这一目标?
感谢您的支持。
【问题讨论】:
标签: postgresql jooq