Re: Return results for PQexec vs PQexecP* - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Return results for PQexec vs PQexecP*
Date
Msg-id 20060517125305.GE15180@svana.org
Whole thread Raw
In response to Return results for PQexec vs PQexecP*  ("Greg Sabino Mullane" <greg@turnstep.com>)
Responses Re: Return results for PQexec vs PQexecP*
List pgsql-hackers
On Wed, May 17, 2006 at 12:45:17PM -0000, Greg Sabino Mullane wrote:
> Someone posted something on the DBD::Pg mailing list recently that
> made me wonder if the user's problem is more of a "don't do that"
> or something that may be solvable with a libpq or protocol change.
>
> Basically, the user has a rule which switches an insert to a select.
> They then want to run the insert, and pull the resulting tuples
> from it. This works fine when using PQexec, as it returns the latest
> result, which is PGRES_TUPLES_OK. However, when using the newer
> PQexec family (PQexecParams and PQexecPrepared), the only thing returned
> is PGRES_COMMAND_OK, which prevents the drawing of any subsequent tuples.

The main problem with PQexec and co is that they don't really do very
well if a single query produces multiple result sets. I'm not sure if
it's defined whether you get the first or the last. In any case, if you
want all the result sets, you need to be looking at PQsendquery and co.

Have a ncie day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Return results for PQexec vs PQexecP*
Next
From: Bruce Momjian
Date:
Subject: Re: pg_dump and backslash escapes