Re: Table functions say "no destination for result data." - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Table functions say "no destination for result data."
Date
Msg-id 20021206131411.C20609-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Table functions say "no destination for result data."  ("Fernando Papa" <fpapa@claxson.com>)
List pgsql-general
On Fri, 6 Dec 2002, Fernando Papa wrote:

>
> Hi everybody!
>
> I'mt playing with new table functions on a fresh postgresql 7.3 over
> Solaris... I want a function who return several rows, so I define that:
>
> -- Function: public.matcheo_cupido_tf(int8)
> CREATE FUNCTION public.match_tf(int8) RETURNS public.vw_match AS '

If you want to return multiple rows you want
RETURNS SETOF public.vw_match

> DECLARE
>    vid ALIAS FOR $1;
>    result int8;
>    vnick varchar;
>    vsex varchar;
>    vdesde int8;
>    vhasta int8;
(add another local, see below)
     r record;

> BEGIN
>
> select into vnick,vsex,vdesde,vhasta
>        par.nick,par.sexo,pb.edaddesde,pb.edadhasta,pb.pais
> from participantes par,
>      perfilesbusqueda pb
> where par.identificador = vid and
>       pb.participante = par.identificador;
>


> select pp.participante,par.nick,pp.sex,pp.edad,pp.desc
> from perfilespropios pp,
>      participantes par
> where pp.sex <> vsex and
>       pp.edad >= vdesde and
>       pp.edad <= vhasta and
>       par.identificador = pp.participante
> ;

You want something like:

for r in select ... loop
 return next r;
end loop;

return;

I believe.


pgsql-general by date:

Previous
From: Vivek Khera
Date:
Subject: Re: 7.3 on OS X HOWTO
Next
From: Joe Conway
Date:
Subject: Re: Table functions say "no destination for result data."