Re: [GENERAL] Passing refcursors between pl/pgsql functions

2010-10-14 Thread Reuven M. Lerner
Hi, Merlin. Thanks for the clarification and explanation; it was quite helpful. I'll give it a shot! Reuven -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Passing refcursors between pl/pgsql functions

2010-10-14 Thread Merlin Moncure
On Thu, Oct 14, 2010 at 12:31 AM, Reuven M. Lerner wrote: > > > 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; >> >

Re: [GENERAL] Passing refcursors between pl/pgsql functions

2010-10-14 Thread Reuven M. Lerner
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; retur

Re: [GENERAL] Passing refcursors between pl/pgsql functions

2010-10-13 Thread Merlin Moncure
On Wed, Oct 13, 2010 at 5:35 AM, Pavel Stehule wrote: >> >> What I would like is something like the following, assuming it's possible: >> >> CREATE OR REPLACE FUNCTION fetch_from_refcursor(ref refcursor) RETURNS >> SETOF test_table AS $$ >> BEGIN >>  RETURN FETCH 1 FROM ref; -- Does not work, but

Re: [GENERAL] Passing refcursors between pl/pgsql functions

2010-10-13 Thread Pavel Stehule
> > What I would like is something like the following, assuming it's possible: > > CREATE OR REPLACE FUNCTION fetch_from_refcursor(ref refcursor) RETURNS > SETOF test_table AS $$ > BEGIN >  RETURN FETCH 1 FROM ref; -- Does not work, but can it? > END $$ language plpgsql; > > Is it possible to do su