Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 779DF9FA05C for ; Fri, 26 Oct 2007 10:25:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 28790-06 for ; Fri, 26 Oct 2007 10:24:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail2007.strasbourg.4js.com (mail2007.strasbourg.4js.com [84.14.60.197]) by postgresql.org (Postfix) with ESMTP id 2C9DA9FC864 for ; Fri, 26 Oct 2007 10:24:56 -0300 (ADT) Received: from [10.0.0.196] (fox.strasbourg.4js.com [10.0.0.196]) (authenticated bits=0) by mail2007.strasbourg.4js.com (8.13.8/8.13.8/Debian-3) with ESMTP id l9QDOpo2002320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 26 Oct 2007 15:24:51 +0200 Message-ID: <4721EA65.2050806@4js.com> Date: Fri, 26 Oct 2007 15:23:49 +0200 From: Sebastien FLAESCH Organization: Four J's Development Tools User-Agent: Thunderbird 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Tom Lane CC: Heikki Linnakangas , pgsql-hackers@postgresql.org, Guillaume ERGAND Subject: Re: PostgreSQL 8.3, libpq and WHERE CURRENT OF References: <4721BAFE.3080601@4js.com> <4721BF34.80901@enterprisedb.com> <4721DECF.80401@4js.com> <10801.1193404182@sss.pgh.pa.us> In-Reply-To: <10801.1193404182@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.91.2/4599/Fri Oct 26 13:27:38 2007 on mail2007.strasbourg.4js.com X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/1333 X-Sequence-Number: 109701 Tom Lane wrote: > Sebastien FLAESCH writes: >> Does a simple PQPrepare() with a SELECT statement not create a cursor on >> the server side? > > No. A prepared statement is just a query plan, not a query-in-progress. Yes of course, I meant PQprepare() + PQexecPrepared() ... > > The Bind/Execute messages sent by PQexecPrepared create something akin > to a cursor, but libpq doesn't expose any API for fetching one row at a > time in that context, so there's no way to use the "current row" anyway. OK... that makes total sense (sorry I jump from one database to another and sometimes I forget implementation details of a specific driver). Sounds like I need to rework my driver to enable row by row fetching with the DECLARE CURSOR + FETCH commands... right? As I wrote: I knew these commands before, but for some reason I did not use that solution because I faced problems. I started with PostgreSQL 7.1 so maybe there was some limitation that does no more exist in 8.x ... Maybe it was because there is not real OPEN command, so you can't distinguish the preparation phase from the execution phase with the DECLARE CURSOR instruction... Or maybe because cursors could only exist inside a transaction block? Just found this in the 7.1 doc: http://www.postgresql.org/docs/7.1/static/sql-declare.html " ERROR: DECLARE CURSOR may only be used in begin/end transaction blocks This error occurs if the cursor is not declared within a transaction block. " Anyway... Thanks a lot guys for these quick answers. That changes from Oracle or SQL Server support. Seb