From: | "Gilberto Castillo" <gilberto(dot)castillo(at)etecsa(dot)cu> |
---|---|
To: | "Guillermo E(dot) Villanueva" <guillermovil(at)gmail(dot)com> |
Cc: | "pgsql-es-ayuda" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: RETURNS TABLE |
Date: | 2013-02-27 20:08:55 |
Message-ID: | 56615.192.168.207.54.1361995735.squirrel@webmail.etecsa.cu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
> Amigos no puedo encontrar ni en la doc oficial ni en google algo muy
> simple, quiero declarar una función de tipo tabla que va a devolver 3 o 4
> datos nada mas en una tabla de una sola columna, esos datos provienen de
> unos cálculos
> Intenté algo así:
> CREATE OR REPLACE FUNCTION mifuncion(parametros) RETURNS table(columna
> integer) AS
> $BODY$
> declare
> li_retorno integer := -1;
> li_retorno_ext integer := -1;
> ...
> ...
>
> begin
> ...
> ...
> columna := li_retorno;
> return next;
> if li_retorno_ext <> -1 then
> columna := li_retorno_ext;
> return next;
> end if;
> end;
> $BODY$
> LANGUAGE plpgsql
>
> Cuando debería devolver dos filas, me devuelve uno solo, estoy seguro que
> esa no es la forma de ir armando fila por fila. Cual sería la forma? Una
> tabla temporal adentro de la función?
> Desde ya muchas gracias
>
prueba utilizar return query en vez del return next
Saludos,
Gilberto Castillo
La Habana, Cuba
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/plain | 179 bytes |
unknown_filename | text/plain | 157 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | marcelo mendoza | 2013-02-27 20:13:35 | Re: RETURNS TABLE |
Previous Message | Guillermo E. Villanueva | 2013-02-27 19:59:11 | RETURNS TABLE |