From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Hart <tjhart@mac.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq and multiple selects in a single query
Date: Sat, 28 Dec 2002 16:23:27 -0500
Message-ID: <4676.1041110607@sss.pgh.pa.us> (raw)
In-Reply-To: <E4A80FA6-1A38-11D7-96DD-000393460410@mac.com>
References: <E4A80FA6-1A38-11D7-96DD-000393460410@mac.com>
Tim Hart <tjhart@mac.com> writes:
> Would it be worth the effort to add to and/or modify the libpq API so
> that multiple selects could be sent to the server in a single request
> and response?
You can do it already. See PQsendQuery and PQgetResult.
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/libpq-async.html
mentions this specifically:
PQexec can return only one PGresult structure. If the submitted
command string contains multiple SQL
commands, all but the last PGresult are discarded by PQexec.
There is a lot of other cruft here to allow nonblocking interaction with
the server, but if all you care about is multiple commands sent in a
single string, you only need
PQsendQuery(...);
while ((res = PQgetResult(...)))
{
process result;
PQclear(res);
}
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, tjhart@mac.com
Subject: Re: libpq and multiple selects in a single query
In-Reply-To: <4676.1041110607@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox