From: | Leonardo Boet Sánchez <boet(at)gtm(dot)tel(dot)etecsa(dot)cu> |
---|---|
To: | "pgsql-es-ayuda" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | RE: Retornando registros desde funcion (pl/pgsql) |
Date: | 2005-03-17 15:54:31 |
Message-ID: | 8833BE7BC6607C468C4F07FEBAB9E6ECC87EFC@srvgtm.gtm.tel.etecsa.cu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Discúlpame pero con esta documentación hay que ser adivino...
Ya hice lo que me dijiste, de hecho ya lo había probado con returns setof record.
Esto es lo que me dijiste:
CREATE OR REPLACE FUNCTION temp() RETURNS SETOF record AS
$body$
declare
aa record;
begin
select into aa col from test;
next;
return next;
end;
$body$
LANGUAGE 'plpgsql'
select * from temp() as foo(col varchar);
Esto me devuelve: ERROR: RETURN NEXT must specify a record or row variable in function returning tuple at or near ";" at character 79
Todo parece indicar que debo ponerle la variable record:
CREATE OR REPLACE FUNCTION temp() RETURNS SETOF record AS
$body$
declare
aa record;
begin
select into aa col from test;
next;
return next aa;
end;
$body$
LANGUAGE 'plpgsql'
Y esto devuelve: ERROR: control reached end of function without RETURN
Gracias nuevamente
Boet
-----Mensaje original-----
De: Alvaro Herrera [mailto:alvherre(at)dcc(dot)uchile(dot)cl]
Enviado el: jueves, 17 de marzo de 2005 09:34
Para: Leonardo Boet Sánchez
CC: pgsql-es-ayuda
Asunto: Re: [pgsql-es-ayuda] Retornando registros desde funcion (pl/pgsql)
On Thu, Mar 17, 2005 at 10:18:53AM -0500, Leonardo Boet Sánchez wrote:
> CREATE OR REPLACE FUNCTION temp1() RETURNS record AS
^^^^^^
debe ser SETOF record
> return aa;
^^^^^^
debe ser RETURN NEXT
Lee la documentacion.
--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"Lo esencial es invisible para los ojos" (A. de Saint Exúpery)
From | Date | Subject | |
---|---|---|---|
Next Message | angel Iracheta | 2005-03-17 16:09:56 | Fwd: Retornando registros desde funcion (pl/pgsql) |
Previous Message | Alvaro Herrera | 2005-03-17 15:48:51 | Re: Retornando registros desde funcion (pl/pgsql) |