Table Aliases

From: "John C(dot) Frickson" <john(at)frickson(dot)us>
To: PostgreSQL ODBC List <pgsql-odbc(at)postgresql(dot)org>
Subject: Table Aliases
Date: 2014-06-10 03:30:50
Message-ID: 1402371050.2977.15.camel@server.frickson.pvt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

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?

Thanks,
John

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Inoue, Hiroshi 2014-06-10 04:15:25 Re: Re: Inconsistency between JDBC and ODBC drivers when dealing with TIMESTAMP WITH TIME ZONE
Previous Message Adrian Klaver 2014-06-10 03:18:56 Re: Re: Inconsistency between JDBC and ODBC drivers when dealing with TIMESTAMP WITH TIME ZONE