#15292·jOOQ

Wrong or missing runtime meta data for indexes with DESC column expressions

Author: mgraminCreated Jun 28, 2023Updated Sep 8, 2026
LabelsT: DefectC: FunctionalityC: Code GenerationP: MediumE: All Editions

Expected behavior

I have a simple table with a desc index:

sql
CREATE TABLE COUNTRIES (
    COUNTRY_ID CHAR (2 BYTE) NOT NULL,
    COUNTRY_NAME VARCHAR2 (40 BYTE),
    REGION_ID NUMBER);
   
CREATE INDEX COUNTRIES_COUNTRY_NAME_IDX ON TEST.COUNTRIES (COUNTRY_NAME desc);

We expect that Oracle META will correctly export the DDL for this type of index

Actual behavior

However, jOOQ exports the DDL for this table and index, as follows:

sql
create table "TEST"."COUNTRIES" (
  "COUNTRY_ID" char(2) not null,
  "COUNTRY_NAME" varchar2(40),
  "REGION_ID" number
)
create index "TEST"."COUNTRIES_COUNTRY_NAME_IDX" on "TEST"."COUNTRIES"(SYS_NC00004$ asc)

This leads to an error during execution:

java
org.jooq.exception.DataAccessException: SQL [create index "TEST"."COUNTRIES_COUNTRY_NAME_IDX" on "TEST"."COUNTRIES"(SYS_NC00004$ asc)]; ORA-00904: "SYS_NC00004$": Invalid Identifier

Steps to reproduce the problem

Create a table in DB:

sql
CREATE TABLE COUNTRIES (
    COUNTRY_ID CHAR (2 BYTE) NOT NULL,
    COUNTRY_NAME VARCHAR2 (40 BYTE),
    REGION_ID NUMBER);
   
CREATE INDEX COUNTRIES_COUNTRY_NAME_IDX ON TEST.COUNTRIES (COUNTRY_NAME desc);

Run this code:

java
        Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "test", "test");
        Configuration configuration = new DefaultConfiguration().set(conn).set(SQLDialect.ORACLE);
        Meta meta = using(configuration).meta();

        Arrays.stream(meta.filterSchemas(v -> v.getName().equalsIgnoreCase("test"))
                        .ddl()
                        .queries())
                .map(Object::toString)
                .forEach(System.out::println);

Execute the resulting query against a different database or schema:

sql
        Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "test", "test");
        Configuration configuration = new DefaultConfiguration().set(conn).set(SQLDialect.ORACLE);
        Meta meta = using(configuration).meta();

        Arrays.stream(meta.filterSchemas(v -> v.getName().equalsIgnoreCase("test"))
                        .ddl()
                        .queries())
                .map(Object::toString)
                .forEach(System.out::println);

jOOQ Version

jOOQ Professional Edition 3.18.4

Database product and version

Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production

Java Version

openjdk 17.0.2 2022-01-18

OS Version

Microsoft Windows [Version 10.0.19044.2846]

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

com.oracle.database.jdbc:ojdbc11:23.2.0.0