Re: Wrong column names in ResultSetMetaData

From: "Mike Martin" <mmartin(at)vieo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Wrong column names in ResultSetMetaData
Date: 2004-08-02 23:16:46
Message-ID: cemi1o$2bur$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Oliver Jowett wrote:
> > The only way to "name" a SQL query column is with AS. There's
> > corroboration in DatabaseMetaData:
> >
> > public boolean supportsColumnAliasing() throws SQLException
> >
> > Retrieves whether this database supports column aliasing.
> > If so, the SQL AS clause can be used to provide names for
> > computed columns or to provide alias names for columns as
> > required.
> >
> > In both cases, "names" and not "labels".
>
> Is an "alias name" the same as a "column name"?

In SQL, yes. A result column has a name, and the AS clause is
the way to reassign that name.

Try this on your favorite DBMS:

SELECT COL FROM (SELECT COL AS FOO FROM T) T1

It fails because the parenthesized query result has no column
named COL.

Mike

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-08-02 23:57:26 Re: Wrong column names in ResultSetMetaData
Previous Message Mike Martin 2004-08-02 23:06:35 Re: Wrong column names in ResultSetMetaData