plpgsql cursors, fetching more than one row

From: "Magnus Naeslund(t)" <mag(at)fbab(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql cursors, fetching more than one row
Date: 2005-06-15 16:38:46
Message-ID: 42B05996.6060300@fbab.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I was thinking of using cursors as a paging mechanism for an application.
Let's say I need to fetch <pagenr> from a table.
If I use these commands from the client it works:

BEGIN WORK;
DECLARE my_cursor CURSOR FOR
SELECT * FROM test1 ORDER BY id ASC
FOR READ ONLY;

MOVE <pagenr*pagesize> IN my_cursor;
FETCH <pagesize> FROM my_cursor;

CLOSE my_cursor;
COMMIT WORK;

Nice and easy.

But how can I do this from within PLPGSQL?
I see no way of fetching more than one (and less than ALL) row and at
the same time process them within the procedure itself.

Probably I'm missing something simple here...?

Regards,
Magnus

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-06-15 16:50:06 Re: enebling regular user to create new users ?
Previous Message David Siebert 2005-06-15 16:30:09 Re: PostgreSQL Client Aplications ?