From: | "Rodrigo Moreno" <rodrigo(dot)miguel(at)terra(dot)com(dot)br> |
---|---|
To: | <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | How to use PQconsumeInput and PQisBusy correctly ? |
Date: | 2005-03-13 15:56:32 |
Message-ID: | 20050313155643.687B23C00B@talara.terra.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
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);
}
}
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-03-13 18:54:14 | Re: How to use PQconsumeInput and PQisBusy correctly ? |
Previous Message | Peter Much | 2005-03-13 15:05:04 | Upd: [Tcl] did pgaccess ever work with kerberos? |