| From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
|---|---|
| To: | Joe Conway <mail(at)joeconway(dot)com> |
| Cc: | Postgresql Novice List <pgsql-novice(at)postgresql(dot)org> |
| Subject: | Re: use cursor in a function |
| Date: | 2003-06-17 17:44:50 |
| Message-ID: | 20030617174449.GA8576@campbell-lange.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
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?
So far I've only been able to get a clue from:
1) Define function
create or replace function mycur(refcursor) returns refcursor AS '
BEGIN
open $1 for select * from abc;
RETURN $1;
END;
' LANGUAGE 'plpgsql';
2) Call function
temporary=> select mycur('cur');
mycur
-------
cur
(1 row)
3) Try to find end of cursor
temporary=> move 99 from cur;
MOVE 5
On 17/06/03, Joe Conway (mail(at)joeconway(dot)com) wrote:
> Rory Campbell-Lange wrote:
> >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?
>
> It's hard to offer advice (at least for me) without more context. What
> are you trying to accomplish (in more detail), and in what type of
> application (web, fat client, etc)?
--
Rory Campbell-Lange
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joe Conway | 2003-06-17 18:19:58 | Re: use cursor in a function |
| Previous Message | Harry Broomhall | 2003-06-17 16:39:27 | Re: Commit within a PL/PGSQL procedure |