Subject | getXXX(colname) doesn't work with calculated columns and aliases |
---|---|
Author | Dietrich Schulten |
Post date | 2001-05-21T12:31:23Z |
Hi,
Interclient has a problem with getXXX(colname) under the following
circumstances, and I think David Jencks' JDBC driver might be affected as
well.
First some background:
Interbase seems to return no column name for calculated columns or a
possibly ambiguous column name, depending what you are calculating.
Aggregate functions use the name of the function as column name (MAX),
calculations such as col1 * col2 return an empty column name.
The effect is, getXXX(colname) cannot find calculated columns because
resultset.findColumn(colname) fails. This is no surprise, considering the
column naming scheme for calculated columns.
However, using aliases doesn't help either. The only thing that helps are
ordinal numbers instead of column names: getXXX(int) works.
For a JDBC driver this is quite unfortunate, because you usually expect
to be able to use getXXX(colname) in applications, especially in
applications that rely heavily on metadata to allow user defined queries etc.
I'm not sure what would be the best way, maybe it wouldn't be very
difficult to guarantee a meaningful column name on engine level. If not,
the driver would have to build an internal map, make up unique column
names for calculated columns and handle findColumn(String) based on this
map.
I tend to think that this should be done on engine or at least on driver
level. Otherwise we force applications to rely solely on ordinal numbers
and implement a name-alias-ordinal number map themselves.
Opinions? Has anybody started to work on this already?
Dietrich Schulten
Interclient has a problem with getXXX(colname) under the following
circumstances, and I think David Jencks' JDBC driver might be affected as
well.
First some background:
Interbase seems to return no column name for calculated columns or a
possibly ambiguous column name, depending what you are calculating.
Aggregate functions use the name of the function as column name (MAX),
calculations such as col1 * col2 return an empty column name.
The effect is, getXXX(colname) cannot find calculated columns because
resultset.findColumn(colname) fails. This is no surprise, considering the
column naming scheme for calculated columns.
However, using aliases doesn't help either. The only thing that helps are
ordinal numbers instead of column names: getXXX(int) works.
For a JDBC driver this is quite unfortunate, because you usually expect
to be able to use getXXX(colname) in applications, especially in
applications that rely heavily on metadata to allow user defined queries etc.
I'm not sure what would be the best way, maybe it wouldn't be very
difficult to guarantee a meaningful column name on engine level. If not,
the driver would have to build an internal map, make up unique column
names for calculated columns and handle findColumn(String) based on this
map.
I tend to think that this should be done on engine or at least on driver
level. Otherwise we force applications to rely solely on ordinal numbers
and implement a name-alias-ordinal number map themselves.
Opinions? Has anybody started to work on this already?
Dietrich Schulten