Re: existen stored procedures?

From: "keyser soze" <bajopalabra(dot)ar(at)gmail(dot)com>
To: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: existen stored procedures?
Date: 2008-10-17 15:08:38
Message-ID: 0dc601c9306a$3f900700$140b000a@siga.frba.utn.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

mil gracias, Álvaro
lo voy a probar

ks

----- Original Message -----
From: "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>
To: "bajopalabra.ar" <bajopalabra(dot)ar(at)gmail(dot)com>
Cc: <pgsql-es-ayuda(at)postgresql(dot)org>
Sent: Friday, October 17, 2008 12:01 PM
Subject: Re: [pgsql-es-ayuda] existen stored procedures?

> bajopalabra.ar escribió:
>
> > el tema de la devolución de varios lotes
> > de última, lo puedo llegar a manejar en otra capa
>
> Puedes retornar SETOF refcursor en una función, y de cada cursor obtener un
> resultado diferente. Prueba algo así:
>
> alvherre=# create or replace function refcursors () returns setof refcursor
> language plpgsql as $$
> declare
> cursor1 refcursor;
> cursor2 refcursor;
> begin
> open cursor1 for values (1), (2), (3);
> return next cursor1;
> open cursor2 for values ('foo'), ('bar'), ('baz');
> return next cursor2;
> end;
> $$
> ;
> CREATE FUNCTION
> alvherre=# begin;
> BEGIN
> alvherre=# select * from refcursors();
> refcursors
> --------------------
> <unnamed portal 3>
> <unnamed portal 4>
> (2 filas)
>
> alvherre=# fetch all from "<unnamed portal 3>";
> column1
> ---------
> 1
> 2
> 3
> (3 filas)
>
> alvherre=# fetch all from "<unnamed portal 4>";
> column1
> ---------
> foo
> bar
> baz
> (3 filas)
>
> alvherre=# commit;
> COMMIT
>
>
> --
> Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4
> "In a specialized industrial society, it would be a disaster
> to have kids running around loose." (Paul Graham)

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Felipe de Jesús Molina Bravo 2008-10-17 15:31:15 Re: estructuras jerárquicas, no relacionales
Previous Message Alvaro Herrera 2008-10-17 15:01:36 Re: existen stored procedures?