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-18 13:35:52 |
Message-ID: | 8833BE7BC6607C468C4F07FEBAB9E6ECC88063@srvgtm.gtm.tel.etecsa.cu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Ya lo tengo
Gracias a todos,
Boet
-----Mensaje original-----
De: pgsql-es-ayuda-owner(at)postgresql(dot)org [mailto:pgsql-es-ayuda-owner(at)postgresql(dot)org] En nombre de josue
Enviado el: jueves, 17 de marzo de 2005 03:24
Para: Leonardo Boet Sánchez
CC: pgsql-es-ayuda
Asunto: Re: [pgsql-es-ayuda] Retornando registros desde funcion (pl/pgsql)
Es que solo lo escribi sin probarlo
> Prueba esto:
> CREATE OR REPLACE FUNCTION temp() RETURNS SETOF test AS
> $body$
> declare
> aa test%rowtype;
> begin
> select into aa col from test;
> next;
> return next;
> end;
> $body$
> LANGUAGE 'plpgsql'
Este funciona:
drop function temp();
drop table test;
create table test (i int, ii int);
insert into test values (1,1);
insert into test values (2,1);
insert into test values (3,1);
insert into test values (4,1);
insert into test values (5,1);
CREATE OR REPLACE FUNCTION temp() RETURNS SETOF test AS
$body$
declare
aa test%rowtype;
begin
for aa in select * from test
loop
return next aa;
end loop;
return ;
end;
$body$
LANGUAGE 'plpgsql';
select * from temp();
--
Sinceramente,
Josué Maldonado.
... "Te enamoras de alguien pero ese alguien no se enamora de ti, otras
personas que no te interesan se enamoran de ti."
---------------------------(fin del mensaje)---------------------------
TIP 10: visita nuestro canal de IRC #postgresql-es en irc.freenode.net
From | Date | Subject | |
---|---|---|---|
Next Message | Alberto Pia | 2005-03-18 14:05:43 | Mayus/Min Usuario de Base de Datos |
Previous Message | Roberto Cesar Najera | 2005-03-18 08:50:19 | consulta |