Search Postgresql Archives

Re: set returning functions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>:
> 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@xxxxxxxxxxxxxx so that your
>        message can get through to the mailing list cleanly
>

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux