From aa33496cde97b34996519f0dbda3c67ca1e22493 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 20 Nov 2020 13:50:26 +0100 Subject: [PATCH] [jOOQ/jOOQ#10989] Cannot use MERGE with SELECT: [42XAL]: The source table of a MERGE statement must be a base table or table function. --- .../src/main/java/org/jooq/impl/InsertQueryImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java index 9446211cf3..1eaf72ef1c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java @@ -586,13 +586,23 @@ final class InsertQueryImpl extends AbstractStoreQuery impl - case DERBY: case H2: case HSQLDB: { ctx.visit(toMerge(ctx.configuration())); break; } + case DERBY: { + + // [#10989] Cannot use MERGE with SELECT: [42XAL]: The source table of a MERGE statement must be a base table or table function. + if (select != null) + ctx.visit(toInsertSelect(ctx.configuration())); + else + ctx.visit(toMerge(ctx.configuration())); + + break; + } + default: { ctx.visit(toInsertSelect(ctx.configuration())); break;