pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Inoue <inoue@tpf.co.jp>
To: John C. Frickson <john@frickson.us>
To: PostgreSQL ODBC List <pgsql-odbc@postgresql.org>
Subject: Re: Table Aliases
Date: Tue, 10 Jun 2014 13:50:02 +0200
Message-ID: <5396F0EA.9060402@tpf.co.jp> (raw)
In-Reply-To: <1402371050.2977.15.camel@server.frickson.pvt>
References: <1402371050.2977.15.camel@server.frickson.pvt>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

(2014/06/10 5:30), John C. Frickson wrote:
> Assume the following query:
>
>    SELECT * FROM some_schema_name.some_table_name a
>      LEFT JOIN other_schame_name.some_table_name b
>      ON a.Foo=b.Bar
>
> Notice that the schemas are different, but the table names are the same.
> Now suppose both tables have an "Id" field. As I go through the columns,
> I call (among other things):
>
>    SQLColAttribute(hstmt, colnum, SQL_DESC_BASE_TABLE_NAME, (UCHAR*)tablename, sizeof(tablename), &lth, NULL);
>    SQLColAttribute(hstmt, colnum, SQL_DESC_TABLE_NAME, (UCHAR*)alias, sizeof(alias), &lth, NULL);
>
> The first call (SQL_DESC_BASE_TABLE_NAME) would return "some_table_name"
> for the Id columns in both schemas.
>
> When MySQL is the backend database, the second call (SQL_DESC_TABLE_NAME)
> would return "a" and "b" for the to Id columns, i.e. the table aliases.
> With PostgreSQL, the second call also returns "some_table_name". I can't
> find any attribute that has the table alias.
>
> Is there a way to get the table alias, or do I just have to code around it
> somehow?

It's not that easy to get the information for the driver and you can't
get if using the current driver unfortunately.
Servers return various infromations like column alias, table oid etc
in response to DESCRIBE request but don't return table alias.

regards,
Hiroshi Inoue


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (2+ messages)

Message-ID: <5396F0EA.9060402@tpf.co.jp>
Permalink:  ../5396F0EA.9060402@tpf.co.jp/
Also on:    postgresql.org/message-id/5396F0EA.9060402@tpf.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, john@frickson.us
  Subject: Re: Table Aliases
  In-Reply-To: <5396F0EA.9060402@tpf.co.jp>
  References: <1402371050.2977.15.camel@server.frickson.pvt> <5396F0EA.9060402@tpf.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox