pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Table Aliases
2+ messages / 2 participants
[nested] [flat]

* Table Aliases
@ 2014-06-10 03:30 John C. Frickson <john@frickson.us>
  2014-06-10 11:50 ` Re: Table Aliases Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 2+ messages in thread

From: John C. Frickson @ 2014-06-10 03:30 UTC (permalink / raw)
  To: 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




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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Table Aliases
  2014-06-10 03:30 Table Aliases John C. Frickson <john@frickson.us>
@ 2014-06-10 11:50 ` Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 0 replies; 2+ messages in thread

From: Hiroshi Inoue @ 2014-06-10 11:50 UTC (permalink / raw)
  To: John C. Frickson <john@frickson.us>; pgsql-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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-06-10 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 03:30 Table Aliases John C. Frickson <john@frickson.us>
2014-06-10 11:50 ` Hiroshi Inoue <inoue@tpf.co.jp>

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