From: Pavel Stehule <pavel.stehule@gmail.com>
To: Rhys Stewart <rhys.stewart@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: set returning functions.
Date: Tue, 25 Sep 2007 00:09:38 +0200
Message-ID: <162867790709241509k16bbe691v94c9ef2748fbbba@mail.gmail.com> (raw)
In-Reply-To: <189966030709211129t7147b726w25f415489f25b874@mail.gmail.com>
References: <189966030709211129t7147b726w25f415489f25b874@mail.gmail.com>
Hello Rhys
its not mystery
create or replace function mysrf(a integer)
returns integer
as $$
begin
for i in 1..a loop
return next i; -- <<<< important
end loop;
return;
end;
$$ language plpgsql;
you can call select * from mysrf(10);
Regards
Pavel Stehule
2007/9/21, Rhys Stewart <rhys.stewart@gmail.com>:
> Hi all,
>
> How can one make a set-returning function behave like
> generate_series(). If I cobble up an srf with plpgsql i have to do
> select * from mysrf().
> But i can do select generate_series(1,10) or select this, that,the
> other,generate_series(1,5) from sometable. Essentially I would like to
> be able to have my srf behave like that.
>
>
>
>
> Rhys
> Live Long & Prosper | Peace & Love
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pavel.stehule@gmail.com, rhys.stewart@gmail.com
Subject: Re: set returning functions.
In-Reply-To: <162867790709241509k16bbe691v94c9ef2748fbbba@mail.gmail.com>
References: <189966030709211129t7147b726w25f415489f25b874@mail.gmail.com> <162867790709241509k16bbe691v94c9ef2748fbbba@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox