Re: libpq and multiple selects in a single query - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: libpq and multiple selects in a single query
Date
Msg-id 4676.1041110607@sss.pgh.pa.us
Whole thread Raw
In response to libpq and multiple selects in a single query  (Tim Hart <tjhart@mac.com>)
List pgsql-interfaces
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


pgsql-interfaces by date:

Previous
From: "."@babolo.ru
Date:
Subject: Re: libpq and multiple selects in a single query
Next
From: Stefan Reuschke
Date:
Subject: compiling 7.2.3 with tcl -- tcl.h