Re: C++: headache with PgDatabase::GetValue (int, string) - Mailing list pgsql-interfaces

From Carlos Moreno
Subject Re: C++: headache with PgDatabase::GetValue (int, string)
Date
Msg-id 200202181104.AA4130865386@mochima.com
Whole thread Raw
In response to C++: headache with PgDatabase::GetValue (int, string)  ("Carlos Moreno" <moreno@mochima.com>)
List 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! 

Carlos
--



pgsql-interfaces by date:

Previous
From: Karri Kaksonen
Date:
Subject: international characters and pg_select
Next
From: Michael Meskes
Date:
Subject: Re: odbc on unix