From: Christoph Haller <ch@rodos.fzk.de>
To: alberto@unex.es
To: pgsql-interfaces@postgresql.org
Subject: Re: ColumnName and ColumnNumber in libpq (C interface)
Date: Mon, 15 Sep 2003 09:59:22 +0200
Message-ID: <3F65715A.BDCAD1FB@rodos.fzk.de> (raw)
>
> I think this behaviour is not fine:
> I create a table with
> CREATE TABLE foo ("Bar" VARCHAR(1));
>
> I thougth running this helloworldish C program:
>
> #include <stdio.h>
> #include <libpq-fe.h>
> =20
> int main(int argc,char **argv)
> {
> PGconn * conn =3D PQconnectdb("dbname=3Dpruebas");
> PGresult * res =3D PQexec(conn,"SELECT * from foo");
> printf("%s\n",PQfname(res,0));
> printf("%d\n",PQfnumber(res,"Bar"));
> PQfinish(conn);
> }
>
> should print=20
>
> Bar
> 0
>
> but stdout shows
>
> Bar
> -1
>
> What is happening? Any ideas? Is this a bug, a feature or something
I'm m=
> issing?
>
It's something you're missing:
All names are folded to lowercase, except enclosed in double quotes. So
printf("%d\n",PQfnumber(res,"\"Bar\""));
gives you the right result.
Regards, Christoph
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: ch@rodos.fzk.de, alberto@unex.es
Subject: Re: ColumnName and ColumnNumber in libpq (C interface)
In-Reply-To: <3F65715A.BDCAD1FB@rodos.fzk.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox