简体   繁体   English

Jooq更新返回值

[英]Jooq update return value

I try to update rows in table and get results after.我尝试更新表中的行并在之后获得结果。 If I do如果我做

dsl.update(TABLE)
   .set(TABLE.ROW, newRow)
   .where(TABLE.ROW_2.eq(
            dsl.select(ANOTHER_TABLE.ID)
               .from(ANOTHER_TABLE)
               .where(ANOTHER_TABLE.GUID.eq(guid))
   )).execute()

it returns 1. But if I do它返回 1。但是如果我这样做

dsl.update(TABLE)
   .set(TABLE.ROW, newRow)
   .where(TABLE.ROW_2.eq(
            dsl.select(ANOTHER_TABLE.ID)
               .from(ANOTHER_TABLE)
               .where(ANOTHER_TABLE.GUID.eq(guid))
   )).returningResult(TABLE.ROW_3).fetchOne()

it returns empty result.它返回空结果。 But I want to get TABLE.ROW_3 after update.但我想在更新后获得 TABLE.ROW_3。 Whats the problem?有什么问题?

Vertica doesn't support UPDATE.. RETURNING like PostgreSQL, as can be seen in the Vertica docs: https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Statements/UPDATE.htm Vertica 不支持UPDATE.. RETURNING像 PostgreSQL 一样返回,如 Vertica 文档中所示: https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Statements/UPDATE.htm

The jOOQ documentation of UpdateReturningStep::returningResult reflects this by not listing SQLDialect.VERTICA in its @Support annotation: UpdateReturningStep::returningResult的 jOOQ 文档通过未在其@Support注释中列出SQLDialect.VERTICA来反映这一点:

@Support({AURORA_POSTGRES,COCKROACHDB,DB2,FIREBIRD,ORACLE,POSTGRES,SQLSERVER})

There's currently no workaround for this.目前没有解决方法。 If you want to avoid using such API, you could use thejOOQ-checker module in your build to produce compilation errors whenever you use API that is not supported by VERTICA如果您想避免使用这样的 API,您可以在构建中使用jOOQ-checker模块,以便在您使用 VERTICA 不支持的VERTICA时产生编译错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM