db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Kartha <karth...@gmail.com>
Subject Re: Tablealias as column qualifier in resultset
Date Wed, 06 Dec 2006 13:10:23 GMT
Per Newgro wrote:

>Hi,
>
>i've a little question. 
>If i execute the example-statement
>  
>  SELECT MYTABLE.* FROM myTable MYTABLE WHERE MYTABLE:A = 5;
>
>i expected to access the column in resultset by usage of
>
>  Object o = getObject("MYTABLE.A);
>
>But this is throwing a ColumnNotFoundException. The other access is working.
>
>  Object o = getObject("A);
>
>I'm a little bit confused because how is derby solving same column names in a 
>join of two tables, if the columns are not referenced by the qualifier?
>
>Cheers
>Per
>
>  
>
Hello Per,

I have never seen any examples of using "tableName.columnName" with the 
ResultSet.getObject() method.
My understanding   is  the ResultSet.getObject () is expected to use 
only the column names, hence using
the table name qualifier will  not work.  Using only the column names 
should be right approach as
you noticed (getObject("A"))

For cases where the same column names appear in joins of two tables, I  
would qualify those
columns with the respective tables in the query and  use the 
*getObject*(int columnIndex)  instead:

Example; select a.b,b.b from a, b where a.a=b.a


HTH,
Rajesh

Mime
View raw message