2015-05-06 16:07 GMT+02:00 Ben Hood <[email protected]>: > On Wed, May 6, 2015 at 2:28 PM, Lukas Eder <[email protected]> wrote: > > What exactly do you mean by "not picking them up"? As I've mentioned > before, > > table-valued functions are considered to be tables (with parameters), not > > routines, by the code generator. This is why they're listed as: > > Sorry, that was my misunderstanding - I had assumed that the changes > you made meant that these {SETOF VOID, SETOF BIGINT} returning > functions would result in a generated class that inherits from > AbstractRoutine. > > They are however being correctly detected as table valued functions. > > So just put that comment down to my ignorance of the process. >
Well, the log is indeed a bit confusing. I have registered an issue to improve this: https://github.com/jOOQ/jOOQ/issues/4276 > > Is there any reason why you'd need them to be "picked up" as routines, > > explicitly? > > The reason for code to be generated for these functions at all is to > be able to call the function and the compile time check of the input > and output parameters. Whether this is achieved as a subclass of > AbstractRoutine or a subclass of TableImpl makes no difference. > > As I said before, my question stemmed from my lack of understanding, > not from wanting to do something funky. > > So I guess you can use the generated TableImpl artefacts to invoke the > function. That said, I can't seem to find the part of the manual that > relates to the calling convention for this. There's this page here: http://www.jooq.org/doc/latest/manual/sql-building/table-expressions/table-valued-functions/ > For example, this example > works and returns the correct result back: > > Record result = ctx.select(). > from(DO_SOMETHING.call(1L)). > fetchOne(); > > But I was also assuming I that the fetchOne() would be typed something > like: > > Long result = ctx.select(DO_SOMETHING.DO_SOMETHING_). > from(DO_SOMETHING). > fetchOne(). > value1(); > > But the second variant returns an error: Hmm, yes, I haven't thought of that yet. That's tricky. The static table reference DO_SOMETHING is needed to dereference result columns. At the same time, it unfortunately is of type Table<?>, which makes it a compatible argument to the from() clause, even if that doesn't make any sense. Note also, there is a generated method Tables.DO_SOMETHING(Long), so you might also be able to call your function like this: -- 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.
