Skip to content
Advertisement

converting string to number inside Jooq select – Oracle

I am using jooq’s DSL.select in my Java code, I have scenario where I need to determine the index from a string. Used DSL.substring("hello123",6,1) to get the desired index value as string, but no method supporting in DSL to convert it to a number. Example:

JavaScript

the nested substring need to be converted into number

Advertisement

Answer

Converting strings to numbers

Use the CAST expression:

JavaScript

As always, this is assuming the following static import:

JavaScript

Mixing Field<?> expressions with bind values

You’ve mixed your Field<?> expression with a bind value 1 in your SELECT clause. There’s no such convenience overload for SELECT (there would be too many permutations), so you’ll have to wrap the bind value explicitly using:

JavaScript

See also: How do I create a Field<T> from a value T in jOOQ, explicitly?

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