Re: Proposal: real procedures again (8.4)

From: David Fetter <david(at)fetter(dot)org>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Hannu Krosing <hannu(at)skype(dot)net>, Josh Berkus <Josh(dot)Berkus(at)sun(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: real procedures again (8.4)
Date: 2007-10-30 13:15:42
Message-ID: 20071030131542.GS14638@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 30, 2007 at 09:48:24AM +0100, Pavel Stehule wrote:
> 2007/10/30, David Fetter <david(at)fetter(dot)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(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gevik Babakhani 2007-10-30 13:31:52 Proposal TODO Item: SQL-language reference parameters by name
Previous Message Pavel Stehule 2007-10-30 08:48:24 Re: Proposal: real procedures again (8.4)