From: Stephen Powell <stephen_powell@optusnet.com.au>
To: pgsql-admin@postgresql.org
Subject: Re: error in code
Date: Thu, 11 Dec 2003 12:57:44 +1100
Message-ID: <u3cbsi09z.fsf@privacy.net> (raw)
References: <1071033961.1264.7.camel@chi>
On 10 Dec 2003, ashok@kalculate.com wrote:
> I written a code
[...]
Checking for errors is good:
# include <stdio.h>
# include <stdlib.h>
# include <libpq-fe.h>
int main()
{
PGresult *result = NULL;
PGconn *conn = NULL;
int feild;
printf("successful");
conn = PQconnectdb ("ashok");
if (!conn || CONNECTION_BAD == PQstatus(conn)) {
fprintf(stderr, "Connection to database failed.\n");
fprintf(stderr, "%s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
result = PQexec (conn, "select * from bill");
if (!result || PGRES_TUPLES_OK != PQresultStatus(result)) {
fprintf(stderr, "select command returned no tuples\n");
fprintf(stderr, "%s", PQerrorMessage(conn));
exit(EXIT_FAILURE);
}
feild = PQntuples (result);
printf("%d",feild);
PQclear (result);
PQfinish (conn);
printf("hello");
return EXIT_SUCCESS;
}
> when i run the a.out it give nothing.
Not even "successful" or "hello" from the printfs?
> plz help me.
Download the programmers manual from here <http://www.postgresql.org/docs/;
--
Stephen Powell
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: stephen_powell@optusnet.com.au
Subject: Re: error in code
In-Reply-To: <u3cbsi09z.fsf@privacy.net>
References: <1071033961.1264.7.camel@chi> <u3cbsi09z.fsf@privacy.net>
* 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