From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | Juan Carlos Alemán Cuadros <jaleman(at)layconsa(dot)com(dot)pe> |
Cc: | "Andres Duque" <raulandresduque(at)hotmail(dot)com>, "Jeferson Alvarez" <jalvarez(at)renova(dot)com(dot)pe>, "ayuda postgre" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: ayuda |
Date: | 2007-01-06 06:00:54 |
Message-ID: | c2d9e70e0701052200t464c338cue9e0e7d8edcd1315@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On 1/5/07, Juan Carlos Alemán Cuadros <jaleman(at)layconsa(dot)com(dot)pe> wrote:
> Perdón por la intromisión, pero si los resultados tienen distintos numeros
> de campos creo que el UNION no funcionaría o si????
>
en ese caso puedes devolver 2 referencias a cursores:
http://www.postgresql.org/docs/8.2/static/plpgsql-cursors.html
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 | Jaime Casanova | 2007-01-06 06:23:34 | Re: problemon con trigger |
Previous Message | Jeferson Alvarez | 2007-01-06 00:12:24 | [Fwd: Re: postgreSQl trabaja con XML?] |