Re: Proposal: real procedures again (8.4)
От | David Fetter |
---|---|
Тема | Re: Proposal: real procedures again (8.4) |
Дата | |
Msg-id | 20071030131542.GS14638@fetter.org обсуждение исходный текст |
Ответ на | Re: Proposal: real procedures again (8.4) ("Pavel Stehule" <pavel.stehule@gmail.com>) |
Список | pgsql-hackers |
On Tue, Oct 30, 2007 at 09:48:24AM +0100, Pavel Stehule wrote: > 2007/10/30, David Fetter <david@fetter.org>: > > Based on the example in TFM for PL/PgSQL: > > > > BEGIN; > > CREATE TABLE foo(foo_id SERIAL PRIMARY KEY, foo_text TEXT); > > CREATE TABLE bar(bar_id SERIAL PRIMARY KEY, bar_text TEXT); > > INSERT INTO foo(foo_text) VALUES ('a'),('b'),('c'),('d'); > > INSERT INTO bar(bar_text) VALUES ('e'),('f'),('g'),('h'); > > CREATE FUNCTION wtf(refcursor, refcursor) > > RETURNS SETOF refcursor > > LANGUAGE plpgsql > > AS $$ > > BEGIN > > OPEN $1 FOR SELECT * FROM foo; > > RETURN NEXT $1; > > OPEN $2 FOR SELECT * FROM bar; > > RETURN NEXT $2; > > END; > > $$; > > SELECT * FROM wtf('a','b'); > > FETCH all FROM a; > > FETCH all FROM b; > > ROLLBACK; > > > > disavantages > * it is transaction based, so you have to wait for first set untill > function is completed (it's avantage too, but you havn't choice now) > > * too much lines, for simple task I'm not saying we don't need it. I was just illustrating that it's currently possible to return multiple result sets. Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
В списке pgsql-hackers по дате отправления: