Re: fetching rows

From: Decio Fonini <fonini(at)candidomendes(dot)br>
To: Nikolay Mijaylov <nmmm(at)nmmm(dot)nu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: fetching rows
Date: 2000-10-31 12:54:24
Message-ID: Pine.LNX.4.21.0010311043490.4283-100000@sol.ipanema.candidomendes.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hello, Nikolay,

Don't use cursors; instead, use:
" select * from films limit 25 offset 0 ; "

and on the next query:
" select * from films limit 50 offset 25 ; "

and so on. You have to encode the current offset into the NEXT link,
either making it into a button inside a form, with a hidden field
containing the offset, or making it an HREF with URL-encoded data
(HREF="myform.php?mycounter=50").

I don't remember in which version the LIMIT option appeared; if your
version doesn't support it, move on to 7.0.2!

Have fun!

On Mon, 30 Oct 2000, Nikolay Mijaylov wrote:

> Let say we have a select that returns 100 rows.
>
> I can fetch first 25 with simple sql:
>
> BEGIN WORK;
> DECLARE liahona CURSOR FOR SELECT * FROM films;
> FETCH [FORWARD] 25 IN liahona;
> CLOSE liahona;
> COMMIT WORK;
>
> but how I can fetch rows from 26 to 50? I mean withou fetching first 25. Or
> can I skip first 25?
>
> When i ask this you need to know that Im using PHP in web environment and
> try do this to get more performens from the script (now the script fetch
> all rows, then jump to needed row)
>
>

-------------------------------------------------------
Fight for a free world: no walls, no windows, no gates.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Najm Hashmi 2000-10-31 15:39:31 Need help! parse erro
Previous Message Kovacs Zoltan Sandor 2000-10-31 11:30:55 PLPGSQL examples