How to use PQconsumeInput and PQisBusy correctly ? - Mailing list pgsql-interfaces

From Rodrigo Moreno
Subject How to use PQconsumeInput and PQisBusy correctly ?
Date
Msg-id 20050313155643.687B23C00B@talara.terra.com.br
Whole thread Raw
Responses Re: How to use PQconsumeInput and PQisBusy correctly ?
List 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 by date:

Previous
From: Michael Meskes
Date:
Subject: Re: ECPG - cursor fetch
Next
From: Tom Lane
Date:
Subject: Re: How to use PQconsumeInput and PQisBusy correctly ?