Hi Jacob,

Thanks very much for your enquiry. Very interesting question. I will
comment inline

2016-11-08 14:56 GMT+01:00 Jacob G <[email protected]>:

> I have some questions about calling a custom postgresql function:
>
> 1) I tried using DSL.field to call this postgresql sql function that
> return VOID, as follows:
>
> private static Field<Void> foo(String param) {
>    return DSL.field("ext.foo({0}, {1}, {2})", Void.class, DSL.val(param));
> }
>
>
> But I get this exception from creating the field:
> org.jooq.exception.SQLDialectNotSupportedException: Type class java.lang.
> Void is not supported in dialect DEFAULT
>  at org.jooq.impl.DefaultDataType.getDataType(DefaultDataType.java:803)
>  at org.jooq.impl.DefaultDataType.getDataType(DefaultDataType.java:747)
>  at org.jooq.impl.DSL.getDataType(DSL.java:16970)
>  at org.jooq.impl.DSL.field(DSL.java:7626)
>
> What am I doing wrong?
>

That's just not supported (yet). I have created a feature request for this:
https://github.com/jOOQ/jOOQ/issues/5655

You could make that a Field<Object>, which wouldn't be too wrong, because
in Java, Void is a subtype of Object. The solution that you've found works
as well, but I wonder if there might be a side effect.


> 2) Would DSL.function be more appropriate to use instead of DSL.field in
> question # 1? I wasn't sure how to pass in my argument using DSL.function.
>

That would work as well. You used the plain SQL API, which is much more
powerful.


> 3) In question #1, is there a way to bind the schema name instead of
> hardcoding it in the sql? Or is putting it in the sql the best/only way?
>

The "best" way would be this:

DSL.field("{0}.foo({1}, {2}, {3})", schema(name("ext")), val(...),
val(...), val(...));


Or, alternatively:

DSL.field("{0}({1}, {2}, {3})", name("ext", "foo"), val(...), val(...),
val(...));


I.e. you create an actual org.jooq.Schema reference and put that before the
dot, or you create a qualified org.jooq.Name and put that before the
brackets.

Hope this helps,
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to