From: Rodrigo Moreno <rodrigo.miguel@terra.com.br>
To: pgsql-interfaces@postgresql.org
Subject: How to use PQconsumeInput and PQisBusy correctly ?
Date: Sun, 13 Mar 2005 12:56:32 -0300
Message-ID: <20050313155643.687B23C00B@talara.terra.com.br> (raw)
Hi all,
What's the right way to use pqconsumeinput and pqisbusy ?
The below code could be used to do that ?
Thanks a Lot
Rodrigo Moreno
PS: Please don't worry if some code is wrong, I do not test this code yeat.
void query(PGconn *conn, const char *stmt)
{
PGresult *res;
int nFields;
int i,j;
int send;
send = PQsendQuery(conn, stmt);
if (PQconsumeInput(conn))
{
while (PQisBusy(conn))
{
printf(".");
sleep(500);
PQconsumeInput(conn);
}
res = PQgetResult(conn);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "failed: %s", PQerrorMessage(conn));
PQclear(res);
exit_nicely(conn);
}
nFields = PQnfields(res);
for (i = 0; i < nFields; i++)
printf("%-15s", PQfname(res, i));
printf("\n\n");
for (i = 0; i < PQntuples(res); i++)
{
for (j = 0; j < nFields; j++)
printf("%-15s", PQgetvalue(res, i, j));
printf("\n");
}
PQclear(res);
}
}
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: rodrigo.miguel@terra.com.br
Subject: Re: How to use PQconsumeInput and PQisBusy correctly ?
In-Reply-To: <20050313155643.687B23C00B@talara.terra.com.br>
* 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