Skip site navigation (1) Skip section navigation (2)

Re: C++: headache with PgDatabase::GetValue (int, string)

From: "Carlos Moreno" <moreno(at)mochima(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: C++: headache with PgDatabase::GetValue (int, string)
Date: 2002-02-18 16:04:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
>>     "select Emp.Name, Dept.Name from Emp, Dept where ....... "
>> Now, I (obviously) want to use GetValue (row, "field_name") to 
>> get the values. 
>If you "obviously" want to use a fetch-by-name operation to fetch
>fields, then it'd behoove you to name the columns differently in the
>first place.  For example:
>    select Emp.Name as emp_name, Dept.Name as dep_name from ...

A-ha!!  The archi-known old trick of an alias for the column names!!
:-)  (yeah, ok, so I'm watching too much "Get Smart" lately  :-))

That also solves the second part of my problem (which I forgot to 
mention when I wrote the message), which is when you select an 
expression, such as "SELECT lower(name) .....". 

I still was expecting the GetValue (row, "table.field") idiom to 
work  (I believe it works with the MySQL client API -- I know, I 
know, who cares about that toy  :-)), but this solution is good 
anyway (I mean, it seems like a good idea to do it in the first 
place), and it is universal, so I guess I'll stick to it.

Thanks Tom and Peter for your replies! 


pgsql-interfaces by date

Next:From: Michael MeskesDate: 2002-02-18 16:24:58
Subject: Re: odbc on unix
Previous:From: Ebrahim AhmedDate: 2002-02-18 06:56:53
Subject: jdbc

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group