plpgsql cursors, fetching more than one row - Mailing list pgsql-general

From Magnus Naeslund(t)
Subject plpgsql cursors, fetching more than one row
Date
Msg-id 42B05996.6060300@fbab.net
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: David Siebert
Date:
Subject: Re: PostgreSQL Client Aplications ?
Next
From: Tom Lane
Date:
Subject: Re: enebling regular user to create new users ?