Re: use cursor in a function

From: Joe Conway <mail(at)joeconway(dot)com>
To: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
Cc: Postgresql Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: use cursor in a function
Date: 2003-06-17 18:19:58
Message-ID: 3EEF5BCE.1000900@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Rory Campbell-Lange wrote:
> In a nutshell:
>
> Is there a way of finding out how many rows (ROW_COUNT) are in a cursor
> select? If one can, is there a way of returning a RECORD containing the
> refcursor and the ROW_COUNT?
>

You aren't buying anything by using a cursor. AFAICS the only way that a
cursor would be a benefit, would be if it could persist from page to
page. Then you could grab just the needed tuples without requerying. But
I'm not aware of any way to do that.

So you might as well run a single
"SELECT count(*) ... WHERE your_criteria_here"
to get the overall count once, and then run your LIMIT/OFFSET query
directly for each page.

Joe

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Lynna Landstreet 2003-06-17 18:43:58 Re: Multibyte support and accented characters
Previous Message Rory Campbell-Lange 2003-06-17 17:44:50 Re: use cursor in a function