PQfnumber and duplicate column names....

From: Ralf Hasemann <rhasemann(at)mac(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: PQfnumber and duplicate column names....
Date: 2004-07-28 22:17:41
Message-ID: F1570351-E0E3-11D8-9500-000393D76D50@mac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi everybody,

at the moemnt I am writing a little app that uses the libpq client
library.

The function PQfnumber returns the column number associated with a
given column name.

Here is the spec of the function:

<snip------------------>
PQfnumber Returns the column number associated with the given column
name.
int PQfnumber(const PGresult *res, const char *column_name);

-1 is returned if the given name does not match any column. The given
name is treated like an identifier in an SQL command,
that is, it is downcased unless double-quoted.
For example, given a query result generated from the SQL command

select 1 as FOO, 2 as "BAR";

we would have the results:

PQfnumber(res, "FOO") 0
PQfnumber(res, "foo") 0
PQfnumber(res, "BAR") -1
PQfnumber(res, "\"BAR\"") 1
<snap------------------->

What happens if the statement looks like:

select 1 as FOO, 2 as FOO; (the database has no probs with that)

What result will PQfnumber return ????

PQfnumber(res, "FOO") 0 or 1 ???

Thx for all help!

Ralf Hasemann

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Eduardo Vázquez Rodríguez 2004-07-28 23:38:02 UNIX timestamps
Previous Message Betsy Barker 2004-07-28 21:38:22 Re: Problem assigning return value from function to a