From: | "Fernando Papa" <fpapa(at)claxson(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Table functions say "no destination for result data." |
Date: | 2002-12-06 20:20:03 |
Message-ID: | CB94A4924490EC4A81EDA55BA378B7BA7B848F@exch2k01.buehuergo.corp.claxson.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 '
DECLARE
vid ALIAS FOR $1;
result int8;
vnick varchar;
vsex varchar;
vdesde int8;
vhasta int8;
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
;
return;
END;
' LANGUAGE 'plpgsql' VOLATILE;
So, I pass to the function a number. Inside the function, first I get
some information (select into) about the search profile, and then I do
the select who want to return (vw_match it's a view who have the same
structure of the second select).
The problem is, when I try to execute this function (in PHP) I get this
message:
SELECT match_tf(132);
Warning: pg_query() query failed: ERROR: SELECT query has no destination
for result data. If you want to discard the results, use PERFORM
instead. in /usr/local/apache/htdocs/postgres/ap_tf.php on line 17
I see this in postgresql logfile:
2002-12-06 17:00:13 ERROR: SELECT query has no destination for result
data.
If you want to discard the results, use PERFORM instead.
2002-12-06 17:00:13 WARNING: Error occurred while executing PL/pgSQL
function match_tf
The same error gave me if I try on psql:
cont=# select match_tf(132);
WARNING: Error occurred while executing PL/pgSQL function match_tf
WARNING: line 21 at SQL statement
ERROR: SELECT query has no destination for result data.
If you want to discard the results, use PERFORM instead.
cont=#
What is the problem? Is this a good use of table function?
Thanks in advance!
--
Fernando O. Papa
From | Date | Subject | |
---|---|---|---|
Next Message | Nicolai Tufar | 2002-12-06 20:22:12 | Re: Size for vacuum_mem |
Previous Message | Tom Lane | 2002-12-06 19:56:47 | Re: Size for vacuum_mem |