On Tue, 14 Mar 2000, Ruben Fagundo wrote:


> We are developing a Postgres web application that would return "X"
> results at a time? Is this something that can be handled in Postgres,
> where we can ask for results, 10 at a time, or something like this? I've
> seen it done on other web sites, but I don't know if it's something they
> do at the database level, or in the application.
>

Hello Ruben,

You should use CURSORs, something like:

        DECLARE TheCursor CURSOR FOR
                SELECT Name, FamilyName, Email FROM People
                ORDER BY Email;

prepares a "cursor" --a query where you can move around-- but does not 
return any row. Then:

        MOVE FORWARD 50 IN TheCursor;

this skips the first 50 rows in the query, finally:

        FETCH FORWARD 15 IN TheCursor;

returns the rows 50, 51,..., 64 of the query. Of course, you should
control the cursor (moving and fetching) with Web form variables or
cookies, etc.

An example of this setup (with postgres+php) is in:

        http://dragui.icm.csic.es:8888/dbICM/dbMostra/

Hth,

________________________________________________________________
Evilio Jose del Rio Silvan          Institut de Ciencies del Mar
[EMAIL PROTECTED]          http://members.es.tripod.de/Evilio/
"Something touched me deep inside the day the music died" - D. McLean

Reply via email to