Re: Table functions say "no destination for result data."

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Fernando Papa <fpapa(at)claxson(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Table functions say "no destination for result data."
Date: 2002-12-06 21:20:07
Message-ID: 20021206131411.C20609-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-12-06 21:22:03 Re: Table functions say "no destination for result data."
Previous Message Vivek Khera 2002-12-06 20:55:27 Re: 7.3 on OS X HOWTO