Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 0A185475F6B for ; Wed, 8 May 2002 12:41:51 -0400 (EDT) Received: from simak.acpub.duke.edu (simak.acpub.duke.edu [152.3.232.12]) by postgresql.org (Postfix) with ESMTP id 5FDAE47654C for ; Wed, 8 May 2002 11:16:51 -0400 (EDT) Received: from [152.3.11.193] (bglab2.botany.duke.edu [152.3.11.193]) by simak.acpub.duke.edu (8.11.5/8.11.3/Duke-5.0.0) with ESMTP id g48FGpU24038; Wed, 8 May 2002 11:16:51 -0400 (EDT) Mime-Version: 1.0 X-Sender: chauser@mail-ch.acpub.duke.edu Message-Id: Date: Wed, 8 May 2002 11:16:51 -0400 To: pgsql-sql@postgresql.org From: Charles Hauser Subject: CURSOR/FETCH vs LIMIT/OFFSET Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Archive-Number: 200205/54 X-Sequence-Number: 7690 Hi, re: displaying results of query. Trying to work out details of how to let users page back and forth among a multi-page list of results. Problem: I need to know the total number of tuples the query would return in order to decide if there are more to display. 1) Use CURSOR and FETCH $res= $con->exec( "BEGIN WORK; DECLARE gene_result CURSOR FOR SELECT blah blah ORDER BY blah; FETCH $offset IN gene_result "); $result->ntuple: returns only the number set by $offset, not TOTAL for query. 2) use LIMIT OFFSET same problem, $result->ntuple: returns only the number set by LIMIT, OFFSET, not TOTAL for query. So there has to be a way to glean both the TOTAL and the SUBSET returned? Searching the postgresql archives obviously can deal with this http://archives.postgresql.org/pgsql-sql/ 'Displaying documents 11-20 of total 243 found.' -- Regards, Chuck