Re: Question regarding string returned from PQgetvalue

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Louis Bouchard <louisjbouchard(at)charter(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Question regarding string returned from PQgetvalue
Date: 2004-11-01 15:38:49
Message-ID: 13929.1099323529@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Louis Bouchard <louisjbouchard(at)charter(dot)net> writes:
> The query should return 0 because there are no records in the table as
> of yet. When I run the program however, the value returned is 48.
> I used GDB to look at what was in the string and I saw this information:
> 48 "0"

You seem to have a fundamental confusion between text strings and
machine integers. PQgetvalue is going to return a pointer to a text
string. Use strtol or atoi or some such to convert the string to
an integer.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kumar S 2004-11-02 13:49:33 three table join
Previous Message Louis Bouchard 2004-11-01 11:29:23 Question regarding string returned from PQgetvalue