Re: how many rows? [was Re: fetching rows]

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: Arnaud Vandyck <arnaud(at)ressource-toi(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how many rows? [was Re: fetching rows]
Date: 2000-11-18 00:03:57
Message-ID: 0011171903570A.30061@comptechnews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)comptechnews(dot)com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2000-11-18 00:11:03 Re: how many rows? [was Re: fetching rows]]
Previous Message Max Fonin 2000-11-17 23:13:23 Re: is there a mysql to postgresql sql converter?