Skip to content
Advertisement

Set NULL value in jooq

I have an big query and my problem is setting NULL values using jooq. For example, I have this piece of sql query:

If transform this into jooq implementation something like this will come out:

but this is ambiguous method call.

I made some research, and find this snippet:

but it didn’t work, because it cannot resolve method with jooq.Param<String>.

How should I proceed?

Advertisement

Answer

Your NULL expression must be of the same type as your TEST.ID column. I would imagine this is not a String column, but some numeric one. Irrespective of the actual data type, you can always create a bind value using the data type of another expression, e.g.

If you’re doing this a lot, you could also extract your own utility like this:

Notice, jOOQ has a built-in method NVL2 for this purpose:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement