How to use PQconsumeInput and PQisBusy correctly ?
От | Rodrigo Moreno |
---|---|
Тема | How to use PQconsumeInput and PQisBusy correctly ? |
Дата | |
Msg-id | 20050313155643.687B23C00B@talara.terra.com.br обсуждение исходный текст |
Ответы |
Re: How to use PQconsumeInput and PQisBusy correctly ?
|
Список | 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); } }
В списке pgsql-interfaces по дате отправления: