I was not able to find a way to get sql metadata even when there are no rows returned
with the current Groovy sql stuff, so I subclassed groovy.sql.Sql and added a new
version of eachRow and rows such that each takes an additional "metaClosure" so
that I can feed the metaClosure the result set's meta data. that way, even if I don't have any
rows returned, I can be sure to have the meta data. And I don't have to
delve into the row processing closure to get the meta data from the first row
or anything like that.
I made my own subclass and added the following methods:
public List rows( final String sql,
final Closure metaClosure )
public void eachRow( final String sql,
final Closure metaClosure,
final Closure rowClosure )
So now I can:
def results = sql.rows( query )
I didn't make a groovier version of the metadata class the way there's a
GroovyRowResult and GroovyResultSet class. I was very impressed with how
easy it was to do what I needed to do.
I have attached the methods I added, but they are not in the approved groovy format.