jOOQ icon indicating copy to clipboard operation
jOOQ copied to clipboard

jOOQ generates invalid SQL when using correlated sub queries that use row values on Oracle XE 18

Open alf opened this issue 6 months ago • 20 comments

Expected behavior

Generated SQL should work.

Actual behavior

Generated SQL causes ORA-22922: nonexistent LOB value.

Steps to reproduce the problem

See JavaTest.java for my MCVE.

In short, the following queries does not work against Oracle 18 XE. Note that they do work on Oracle 21 and 23.

ctx.select(
    select(row(val(1), val(1))).asField())
.from(xmltable("1 to 11").column("column_value", INTEGER))
.fetch();

Result from logs:

org.jooq.exception.DataAccessException: SQL [select (select json_array(nvl(null, ?), nvl(null, ?) null on null returning clob) "nested" from DUAL) from xmltable(? columns "column_value" number(10))]; ORA-22922: nonexistent LOB value
ctx.select(
    select(row(val(1), val(1))).asMultiset())
.from(xmltable("1 to 11").column("column_value", INTEGER))
.fetch();

Result from logs:

org.jooq.exception.DataAccessException: SQL [select (select coalesce(json_arrayagg(json_array(t."v0" format json null on null returning clob) format json returning clob), json_array(returning clob)) from (select json_array(nvl(null, ?), nvl(null, ?) null on null returning clob) "v0" from DUAL) t having count(*) = count(*)) from xmltable(? columns "column_value" number(10))]; ORA-22922: nonexistent LOB value

jOOQ Version

3.19.10

Database product and version

Oracle 18 XE

Java Version

OpenJDK 17

JDBC / R2DBC driver name and version (include name if unofficial driver)

No response

alf avatar Aug 09 '24 12:08 alf