For cases where the same column names appear in joins of two tables, you can
use column-Alias, e.g.:

 SELECT  t.TABLENAME AS TABLENAME
       , t2.TABLENAME AS REFTABLENAME
   FROM  SYSTABLES t
      ,  SYSTABLES t2
 WHERE ...

resultSet.getString( TABLENAME );
resultSet.getString( REFTABLENAME );

-----Ursprüngliche Nachricht-----
Von: Rajesh Kartha [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 6. Dezember 2006 14:10
An: Derby Discussion
Betreff: Re: Tablealias as column qualifier in resultset


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

Reply via email to