Re: getColumnLabel return value

From: Barry Lind <blind(at)xythos(dot)com>
To: Gerlits AndrXs <gerlits(at)neotek(dot)hu>
Cc: PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: getColumnLabel return value
Date: 2002-12-16 19:00:24
Message-ID: 3DFE22C8.7000006@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Actually I would say that we currently do return the label. Since we
are dealing with result sets here, we are dealing with queries and not
necessarily tables.

Consider the following query:

select a.FOO as bar1, b.FOO as bar2 from BAZ1 a, BAZ2 b
where a.X = b.X

will return the following information:
getColumnName(1) -> bar1
getColumnLabel(1) -> bar1
getColumnName(2) -> bar2
getColumnLabel(2) -> bar2

This is a limitation of the information the driver gets back from the
server, it only returns the 'label' which the driver then uses for both
columnname and label. Which usually is the columnname (unless you alias
it as above).

For fun consider the following query:

select 'a message' as message, FOO as bar from BAZ

getColumnName(1) -> ??? what should this be since there is no column
getColumnLabel(1) -> message
getColumnName(2) -> should be foo if we were given that information
from the server, but currently is bar
getColumnLabel(2) -> bar

You can also have lots of fun with getTableName() as well when the
'table' may be a subquery in the from clause. It isn't clear what
should be returned in many cases even if the server did support more.

thanks,
--Barry

Gerlits AndrXs wrote:
> I was surprised to see that the getColumnLabel method in the
> ResultSetMetaData object returns the name of the column instead of the
> comment (when available).
>
> The documentation says that the method:
> "Gets the designated column's suggested title for use in printouts and
> displays."
>
> Any thoughts on that?
>
> I'd do it if you guys agree.
>
> Regards
> Andras Gerlits
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dror Matalon 2002-12-16 19:18:20 getTableName
Previous Message Barry Lind 2002-12-16 18:25:06 Re: failing using unicode