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;