Hi, Merlin. You wrote:
> In other words, something like this:
>
> create or replace function test() returns setof foo as
> $$
> declare
> r refcursor;
> f foo;
> i int;
> begin
> open r for select * from foo;
>
> for i in 1..10
> loop
> fetch 1 from r into f;
> exit when not found;
> return next f;
> end loop;
> end;
> $$ language plpgsql;
>
> Having defined refcursor separately from the place it is being used
> really had no bearing on the peculiarities of the 'fetch' statement.
This isn't quite what I was looking for; perhaps I didn't make myself clear.
I want to invoke one function, and get an open refcursor returned. That
much, I know how to do.
I then want to be able to call a second function, repeatedly, which will
essentially perform a "fetch 20" from that open refcursor. The second
function should have an input of a refcursor (already open), and should
return a set of rows from the table on which it was opened.
This isn't the way that I would want to do things, but my client's
application structure seems to require it, at least for now. So, is
there a way to do this?
Reuven
--
Reuven M. Lerner -- Web development, consulting, and training
Mobile: +972-54-496-8405 * US phone: 847-230-9795
Skype/AIM: reuvenlerner