Search Postgresql Archives

Re: Creating a PL/pgSQL function that returns multiple out parameters and refcursor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 3, 2014 at 1:15 AM, Néstor Boscán <nestorjb@xxxxxxxxx> wrote:
> Ho do I create a PL/pgSQL function that returns multiple out parameters and
> a refcursor.

Using a plain "RETURN;" is just but fine, your output parameters are
being set internally in the function:
=# create function myfunction(id_base in int, id1 out int, id2 out varchar)
returns record as $$
  begin
    id1 := id_base * 2;
    id2 := id_base * 3;
    return;
  end;
$$ language plpgsql;
CREATE FUNCTION
=# select * from myfunction(3);
 id1 | id2
-----+-----
   6 | 9
(1 row)
=# select * from myfunction(4);
 id1 | id2
-----+-----
   8 | 12
(1 row)

Regards,
-- 
Michael


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux