Subject | Re: [Firebird-Java] Columns names in resultset |
---|---|
Author | Yves Glodt |
Post date | 2008-08-10T21:02:47Z |
On Sunday 10 August 2008, Roman Rokytskyy wrote:
C.NAME as NAME1 from CUSTOMER C" etc
regards,
Yves
> > when I do rst.getString("C.NAME") it does not work, and theRoman and Steffen, thank you for the information. I will go with "select
> > exception says that the columns name was not found in the result
> > set. Doing rst.getString("NAME") works.
> >
> > Is this normal and expected?
>
> As Steffen wrote - yes.
>
> > This behaviour gives me trouble since I have a query where I do
> > several left-joins on the same table, with different aliases, and I
> > do not see how I can differentiate the colum names.
>
> Even more, the specification requires to match the first column by
> the name. So you even don't have guarantee which column will be
> returned and how to access other columns. So assign aliases to the
> columns.
>
> In general it is always safe to access the columns via their indexes.
> In your case you can use ResultSetMetaData information to get the
> name of the column and the table of the column (but not the table
> alias, in your case "C") for the specified index. This won't work if
> you use the same table more than once in your SQL.
>
> Roman
C.NAME as NAME1 from CUSTOMER C" etc
regards,
Yves