Subject Re: [IB-Java] Re: getXXX(colname) doesn't work with calculated columns and aliases
Author Dietrich Schulten
Hi,


> In my opinion it would to silly to be able to refer to calculated and
> function fields by name if you have not given them a name.

What about an application that takes user defined queries and shows the
result to the user? It is at least no friendly behavior to skip
calculated columns in the display as long as the user doesn't give them
an alias. Using an expression without alias is perfectly legal.

> As for
> user-defined labels it should be simple enough to implement this
> feature.


> For now, you can do something like:
> PreparedStatement ps = ....;
> ResultSet rs = ps.executeQuery();
> int count = rs.getMetaData().getColumnCount();
> Map hm = new HashMap ();
> for ( int i = 1; i <= count ; i++ )
> hm.put(rs.getMetaData().getColumnLabel(i), new Integer(i));


> // Later you can:
> int index = ((Integer) hm.get(label)).intValue();
> Object object = rs.getObject(i);

I'm not sure whether you are talking about the driver or about an
application that uses the driver. In a java application this would mean
to specialize on Interclient's behavior that getXXX(colname) doesn't
always work. Who guarantees that the next driver will work with ordinal
numbers?

As to ambiguous column names, that is a good point. A JDBC driver must
guarantee that findColumn(colname) always works, therefore it should try
to make column names unique by adding the table name.

I'd say, this is an implicit requirement of the JDBC API. I'm not sure if
it isn't thought out well, after all it is about standardized data
retrieval. If Interbase has special ways, the driver must try to hide
that. At least that's what I think at the moment. Any Interbase JDBC
driver should try to do it that way, otherwise it will hamper the use of
Interbase, compared with other databases that always work with
getXXX(colname).

But before looking into the Interclient sources, I'd like to hear your
opinion on this.

Dietrich