Call a function with default value in an SQL statement

Viewed 79

I have this SQL statement:

select pa_bez.divlovs(lovart, lovid) bez, lovid, lovart from divlovs where lovart = ?

pa_bez.divlovs has a third parameter with a default value.

jOOQ generated this method:

public static Field<String> divlovs(String pLovart, String pLovid, String pSprache)

If I use this in the SELECT statment I'll have to pass null and the default value will not used.

How can I translate this query to jOOQ that pa_bez.divlovs is called with only two parameters?

1 Answers

You cannot use the static convenience method if you want to apply the default, you'll have to use the underlying Routine object, e.g.

Divlovs divlovs = new Divlovs();
divlovs.setPLovart(...);
divlovs.setPLovid(...);

List<String> result =
ctx.select(divlovs.asField())
   .from(DIVLOVS)
   .where(DIVLOVS.LOVART.eq(...))
   .fetch();
Related