It doesn't matter whether there is data or not, since you are after
metadata. If you look closer at the API you may notice some `eachRow`
and `rows` methods having `Closure metaClosure` among their
parameters. That closure is called once, even for empty tables, with
the `ResultSetMetaData` as argument.
def colNames
sql.rows('select * from empty_table') { meta ->
colNames = (1..meta.columnCount).collect {
meta.getColumnName(it)
}
}
Another way is to go strait to `DatabaseMetaData` and read columns from there:
def meta = sql.connection.metaData,
cols = meta.getColumns('a_catalog', null, 'empty_table', null)
def colNames = []
while (cols.next()) colNames << cols.getString('column_name')
(Note: be careful here about closing your connection)
Cheers,
Dinko
>
> Thanks!
>
> Dean Del Ponte
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email