Select NULL as column using JOOQ

Baz :

I'm trying to select NULL as a column in my query using JOOQ, so basically something like this:

SELECT name, NULL as 'someColumn' FROM someTable;

I need to do this, because the result needs to include someColumn (as part of a data standard), but we do not have this information in our database. This works fine in plain SQL, but I'm struggling to reproduce this using JOOQ.

Does anyone know how to do this in a query of this form?

context.select(
    SOMETABLE.NAME,
    ... // Other columns here
    DSL.NULL.as("someColumn") // <-- This doesn't exist
)
Lukas Eder :

You can use an inline value

DSL.inline(null)

Depending on your database dialect or query usage, you may need to add a data type to that value, e.g.

DSL.inline(null, SQLDataType.VARCHAR)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=24919&siteId=1