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

Re: newbie libpq question...

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Doug Homoelle <homoelle(at)ll(dot)mit(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: newbie libpq question...
Date: 2004-11-14 01:23:41
Message-ID: 20041114012339.GA73251@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Mon, Nov 08, 2004 at 05:23:59PM -0500, Doug Homoelle wrote:
> 
> 	res = PQexec(conn, "select blah blah blah");
> 	test_int=PQntuples(res);
> 	fprintf(stdout,"number of rows: %f\n",test_int);
> 	test_int=PQnfields(res);
> 	fprintf(stdout,"number of cols: %f\n",test_int);
> 
> where "blah blah blah" is the selection criteria, I get zero rows and
> zero columns.

You're using floating-point (%f) conversions to print integers; use
%d or %i instead.  Some compilers have options to warn you of such
mistakes -- with gcc, for example, you can use -Wall.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

pgsql-interfaces by date

Next:From: L J BayukDate: 2004-11-15 01:49:28
Subject: Re: Where is src/interfaces/libpgtcl?
Previous:From: jing hanDate: 2004-11-11 17:00:50
Subject: about libpq-C FETCH performance issue

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