use cursor in a function

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: use cursor in a function
Date: 2003-06-17 09:19:12
Message-ID: 20030617091912.GA6349@campbell-lange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This is a repost of a question which still confuses me.

I wish to write a function that returns NUM_ROWS for a particular
condition AND a subset of those rows (eg by using LIMIT and OFFSET).

I imagine having function b that returns a reference to a cursor and
NUMROWS. In function a I use the cursor to effectively do the LIMIT and
OFFSET, and append the NUM_ROWS column to all of the results.

Is this sensible, efficient, feasible? I have not used cursors before.

Or should I simply do 2 separate functions, 1 for NUM_ROWS, the
other for the result set I want?

Help much appreciated!
Rory
--
Rory Campbell-Lange
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-06-17 09:39:05 Damn triggers and NEW
Previous Message Jean-Christian Imbeault 2003-06-17 09:11:56 Bad link on techdocs