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

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Table functions say "no destination for result data."
Дата
Msg-id 20021206131411.C20609-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Table functions say "no destination for result data."  ("Fernando Papa" <fpapa@claxson.com>)
Список 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 по дате отправления:

Предыдущее
От: Vivek Khera
Дата:
Сообщение: Re: 7.3 on OS X HOWTO
Следующее
От: Joe Conway
Дата:
Сообщение: Re: Table functions say "no destination for result data."