Search Postgresql Archives

Re: consequent PQsendQueryPrepared() failed: another command is already in progress

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2010-06-16 at 10:26 +0600, Anton Maksimenkov wrote:
> 	if ((res = PQgetResult(conn)) == NULL) {
> 		fprintf(stderr, "PQgetResult() res == NULL");
> 		PQfinish(conn);
> 		return -1;
> 	}
> 	if (PQresultStatus(res) != PGRES_TUPLES_OK) {
> 		fprintf(stderr, "PQgetResult() failed: %s", PQerrorMessage(conn));
> 		PQclear(res);
> 		PQfinish(conn);
> 		return -1;
> 	}
> 


> SECOND: PQsendQueryPrepared() failed: another command is already in progress
> 
> Where I was wrong?
> 

You need to call PQgetResult() again. From the docs
http://www.postgresql.org/docs/9.0/static/libpq-async.html :

"PQgetResult must be called repeatedly until it returns a null pointer,
indicating that the command is done."

After you get a NULL back from PQgetResult, you can execute another
command.


> 
> And another question. Is it possible to simultaneously keep a number
> of prepared queries and run any of them from time to time?

Yes, although a prepared query lasts only as long as the connection.
When you disconnect and reconnect, you will need to prepare them again.

Regards,
	Jeff Davis


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux