Received: from comptechnews.com (cc993546-b.srst1.fl.home.com [24.3.77.52]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAHNw8s76365 for ; Fri, 17 Nov 2000 18:58:08 -0500 (EST) (envelope-from reaster@comptechnews.com) Received: from localhost (localhost [[UNIX: localhost]]) by comptechnews.com (8.9.3/8.9.3) id TAA21258; Fri, 17 Nov 2000 19:03:57 -0500 From: "Robert B. Easter" Date: Fri, 17 Nov 2000 19:03:57 -0500 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="us-ascii" To: Arnaud Vandyck , "pgsql-sql@postgresql.org" References: <00111622091407.30061@comptechnews> <3A14F3E8.1FD2685F@ressource-toi.org> In-Reply-To: <3A14F3E8.1FD2685F@ressource-toi.org> Subject: Re: how many rows? [was Re: fetching rows] MIME-Version: 1.0 Message-Id: <0011171903570A.30061@comptechnews> Content-Transfer-Encoding: 8bit X-Archive-Number: 200011/146 X-Sequence-Number: 177 On Friday 17 November 2000 04:01, Arnaud Vandyck wrote: > "Robert B. Easter" wrote: > > > you can't do that with a cursor, but you can use they mysql-ism called > > > a limit clause. for example, to fetch rows 26-50 from that query, > > > you'd do: > > > > > > select * from films limit 25,26; > > > > > > or > > > > > > select * from files limit 25 offset 26; > > I did know it was possible but did not know how to do, thanks (It was > not my question but I'm glad to see the solution:) > > and how can I know how many rows are returned by the query? > I don't know exactly. I don't know of any way to find the total number of rows in a cursor. If you really need to know, you'll have to run a count(*) first, then make the cursor using the same select almost. Once you get the count(*), you can then use MOVE and FETCH to get the page you want. If someone has done it a better way, I'd like to hear how. However, sometimes it is possible to cache a count(*) value somewhere in the database so it doesn't have to be found everytime - it depends on your database and what the select is if you can store the count in advance somehow. > -- > Arnaud > ( http://www.ressource-toi.org ) -- -------- Robert B. Easter reaster@comptechnews.com --------- - CompTechNews Message Board http://www.comptechnews.com/ - - CompTechServ Tech Services http://www.comptechserv.com/ - ---------- http://www.comptechnews.com/~reaster/ ------------