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

From Carlos Moreno
Subject C++: headache with PgDatabase::GetValue (int, string)
Date
Msg-id 200202171552.AA836829418@mochima.com
Whole thread Raw
Responses Re: C++: headache with PgDatabase::GetValue (int, string)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: C++: headache with PgDatabase::GetValue (int,  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-interfaces
Hi, 

I wonder if this is an oversight in the design of the PgDatabase 
class, or if I'm missing something, or doing something wrong.

Say I have two unrelated tables with fields witht the same name 
(e.g., table Employees, with a field Name, and table Departments, 
also with a field Name).  I have a SELECT statement that returns 
data from both tables, and I need both Name fields: 
   "select Emp.Name, Dept.Name from Emp, Dept where ....... "

Now, I (obviously) want to use GetValue (row, "field_name") to 
get the values. 

If I try GetValue (row, "Name")  I'm in trouble (it won't know 
which one -- and notice that it's not a case of an inner join, 
where the Name will happen to be the same), and if I do 
GetValue (row, "Emp.Name"), it returns NULL -- and the name 
lookup logs an message to stderr. 

Is there a workaround?  (excluding of course the rather infamous 
possibility of using GetValue(int,int) directly...  I have already 
enough trouble with my natural bugs to be asking for more trouble 
:-)) 

Thanks! 

Carlos
--



pgsql-interfaces by date:

Previous
From: Michael Meskes
Date:
Subject: odbc on unix
Next
From: Tom Lane
Date:
Subject: Re: C++: headache with PgDatabase::GetValue (int, string)