Subject Enhancement Request: getSourceColumnName(int column)
Author bjonhale
Hi,

I couldn't find a better place to put in an enhancement request.
Please direct me if there is a better place.

I request that a new method be added to FBResultSetMetaData.java. The
new method would be as follows.

/**
* Get the underlying table column name
*
* @param column the first column is 1, the second is 2, ...
* @return column name
* @exception SQLException if a database access error occurs
*/
public String getSourceColumnName(int column) throws SQLException {
return (getXsqlvar(column).sqlname == null) ?
"" : getXsqlvar(column).sqlname;
}


The reason this method is necessary is to gain access to the actual
column name as is found in the database. This can currently only be
accessed if you call getColumnLabel() (or getColumnName() since it
just calls the former) AND there is no alias name setup.

I still don't understand why getColumnName wouldn't always return the
underlying column name but I did find a few relevant newsgroup posts
that argued for the way it currently works. They also suggested
providing the above getSourceColumnName() as a workable solution. I
think there may also be a need to provide a getSourceTableName() but I
haven't seen the need for it as getTableName seems to return what I
would expect (even when table aliases are used...which is what I'm
particulary interested in.

Here's the relevant post I saw:
http://archives.postgresql.org/pgsql-jdbc/2004-08/msg00020.php

I've added getSourceColumnName() to a version I built for my needs but
would love to have it a part of the standard distribution.

My need for getting access to it is as follows: I'm trying to provide
a dynamic "Order By" functionality for my users. To do an order by
properly everytime, I have to have access to the underlying table
anme/column name in case they have aliased column names.

Thanks,
Brent