From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | "jeferson alvarez" <jalvarez(at)renova(dot)com(dot)pe> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: [Fwd: Como devuelvo mas de un conjunto de registros en una funcion] |
Date: | 2007-01-26 06:41:27 |
Message-ID: | c2d9e70e0701252241r7e6c9a17kc50e3e3674721317@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On 1/23/07, jeferson alvarez <jalvarez(at)renova(dot)com(dot)pe> wrote:
>
> ---------- Forwarded message ----------
> From: jeferson alvarez <jalvarez(at)renova(dot)com(dot)pe>
> To: pgsql-es-ayuda-owner(at)postgresql(dot)org
> Date: Tue, 23 Jan 2007 18:38:44 -0500
> Subject: Como devuelvo mas de un conjunto de registros en una funcion
> Como devuelvo mas de un conjunto de registros en una funcion es decir
> como devuelvo mas de un select en una funcion
> gracias por la ayuda
>
regresa cursores...
http://www.postgresql.org/docs/8.2/static/plpgsql-cursors.html#PLPGSQL-CURSOR-USING
CREATE FUNCTION myfunc(refcursor, refcursor) RETURNS SETOF refcursor AS $$
BEGIN
OPEN $1 FOR SELECT * FROM table_1;
RETURN NEXT $1;
OPEN $2 FOR SELECT * FROM table_2;
RETURN NEXT $2;
END;
$$ LANGUAGE plpgsql;
-- need to be in a transaction to use cursors.
BEGIN;
SELECT * FROM myfunc('a', 'b');
FETCH ALL FROM a;
FETCH ALL FROM b;
COMMIT;
--
Atentamente,
Jaime Casanova
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook
From | Date | Subject | |
---|---|---|---|
Next Message | gbas gbas | 2007-01-26 07:49:00 | Re: Pgplsql extraño |
Previous Message | Guido Barosio | 2007-01-26 05:16:23 | Re: Sitio en espaniol |