Search Postgresql Archives

plpgsql cursors, fetching more than one row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux