2018-03-21 14:34 GMT+01:00 Bear Giles <[email protected]>:

>
> ​where the (mumble) ​involves the ResultSet -> Record tools, unless
> there's a more direct way to get this.
>

Yes. As I said. Build the query using the jOOQ DSL API and let jOOQ execute
the query for you. If you absolutely *need* to run plain SQL queries, you
can still use this workaround:

ctx.select(dt).from("(select dt from jooqtest) jooqtest").fetch();


I don't fully understand your requirements and why you want to do these
things with plain SQL rather than with jOOQ, but you certainly don't need
to reproduce jOOQ's DefaultBinding internals the way you're doing right now.

I know I can't just use a map from sqltype to datatype since many databases
> define additional datatypes so we would have to check for null values and
> that's where we got into trouble before. Better to be a little verbose so
> it's clear that when we add support for new types we do it by adding a
> 'case' statement and a converter.
>

Again, I can't help here without understanding your requirements. From what
you've shown so far, this is either being overengineered, or you have
omitted quite a few requirements :)


> Now I'm wondering about the other side of this - I was thing that I could
> go through the Param list, do the same getSqlType() branch, etc., and that
> it would use the database metadata to determine the correct sqltype. Now
> I'm thinking that the information won't be available since we're using
> sql-based queries instead of queries built up like you did. I need to look
> more closely at how we're doing it now since I know we're able to throw
> data exceptions if someone is trying to convert a BigInteger into a SQL
> type that can't handle it.
>

Even if you *have* to use plain SQL, you can still use the plain SQL
templating API and let jOOQ and jOOQ's Converter / Binding SPIs apply here:
https://www.jooq.org/doc/latest/manual/sql-building/plain-sql-templating

E.g.

ctx.fetch("select dt from jooqtest where dt = {0}", val(myType,
dt.getDataType()));


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