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

Re: ColumnName and ColumnNumber in libpq (C interface)

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: alberto(at)unex(dot)es, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: ColumnName and ColumnNumber in libpq (C interface)
Date: 2003-09-15 07:59:22
Message-ID: 3F65715A.BDCAD1FB@rodos.fzk.de (view raw or flat)
Thread:
Lists: pgsql-interfaces
>
> 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



Responses

pgsql-interfaces by date

Next:From: Lester GodwinDate: 2003-09-15 12:21:23
Subject: remove
Previous:From: Alberto Cabello SanchezDate: 2003-09-15 07:11:25
Subject: ColumnName and ColumnNumber in libpq (C interface)

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