Re: set returning functions.

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Rhys Stewart" <rhys(dot)stewart(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: set returning functions.
Date: 2007-09-24 22:09:38
Message-ID: 162867790709241509k16bbe691v94c9ef2748fbbba@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(dot)stewart(at)gmail(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Douglas McNaught 2007-09-24 22:19:51 Re: trying to migrate to a new server.
Previous Message Reece Hart 2007-09-24 21:58:21 Re: Why the ERROR: duplicate key violates unique constraint "master_pkey" is raised? - Is this a Bug?