concatenating setof functions

From: "Frederick Ross" <madhadron(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: concatenating setof functions
Date: 2007-04-16 19:30:49
Message-ID: b91043270704161230u2e3aeee3q1519194220600f10@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I suspect I am missing a much cleaner way of doing this, but say I
have a function which returns a setof integer, i.e.,

create or replace function testfunc (integer) returns setof integer as $$
declare
i alias for $1;
begin
return next i;
return next i+100;
return;
end
$$ language plpgsql;

I know I can call this as: select * from twohundreds(3);

But say I have a table with an integer column. If I had a pure SQL
function, I could call

select twohundreds(i) from table;

and get a properly concatenated list of the rows resulting from
applying twohundreds to each row of table. This is deprecated
according to the documentation, and it doesn't work at all with
PLPGSQL, so how should I go about doing it?

--
Frederick Ross
Graduate Fellow, (|Siggia> + |McKinney>)/sqrt(2) Lab
The Rockefeller University
Je ne suis pas Fred Cross!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-04-16 19:38:54 Re: concatenating setof functions
Previous Message jdh3rd 2007-04-16 18:38:23 Procurando Freelancer PostgreSQL -- Rio de Janeiro