Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WuKZB-0003Ai-4q for pgsql-odbc@arkaria.postgresql.org; Tue, 10 Jun 2014 11:50:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WuKZA-0004AV-JR for pgsql-odbc@arkaria.postgresql.org; Tue, 10 Jun 2014 11:50:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WuKZ9-00048E-5h for pgsql-odbc@postgresql.org; Tue, 10 Jun 2014 11:50:11 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by makus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WuKZ5-0003Us-0i for pgsql-odbc@postgresql.org; Tue, 10 Jun 2014 11:50:09 +0000 Received: (qmail 8368 invoked by uid 512); 10 Jun 2014 11:50:03 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 10 Jun 2014 11:50:03 -0000 Received: from unknown (HELO ?192.168.1.4?) (183.76.63.174) by sd.tpf.co.jp with SMTP; 10 Jun 2014 11:50:03 -0000 Message-ID: <5396F0EA.9060402@tpf.co.jp> Date: Tue, 10 Jun 2014 13:50:02 +0200 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "John C. Frickson" , PostgreSQL ODBC List Subject: Re: Table Aliases References: <1402371050.2977.15.camel@server.frickson.pvt> In-Reply-To: <1402371050.2977.15.camel@server.frickson.pvt> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org (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), <h, NULL); > SQLColAttribute(hstmt, colnum, SQL_DESC_TABLE_NAME, (UCHAR*)alias, sizeof(alias), <h, 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