Re: Postgres 11 procedures and result sets

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: nospam001-lists(at)jan-kohnert(dot)de, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Postgres 11 procedures and result sets
Date: 2018-10-02 16:33:31
Message-ID: CAHyXU0xkALp3_WmGA7fR8Qt1SftoOHgQOOv9P2e=V_drj0tD4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 1, 2018 at 6:57 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Jan Kohnert <nospam001-lists(at)jan-kohnert(dot)de> writes:
> > I have a question regarding the new stored procedures in Postgres 11 (I tested
> > beta4):
> > I'd like to know if it is somehow possible to get a (or possibly more) result
> > set from selects within the SP, as it is possible in MariaDB, MySQL, or SQL
> > Server.
>
> Not there as of v11, other than the refcursor approach you already know
> about. We hope to have something nicer worked out for v12. There
> are a lot of compatibility issues to sort through :-(

There are a few other ways of dealing with this.

If the data being returned isn't very large, you can stuff multiple
'datasets' into a single json. I do this all the time today, with
functions. Yet another tactic is to create temp tables (maybe ON
COMMIT DROP) and refer to those tables after calling the procedure. I
would strongly consider this if the returned data was large and the
function/procedure was not called at a high rate (making system
catalog thrash in issue). I would probably use these tactics,
especially the json style return, even after multi-result style
invocation were to drop.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Malik Rumi 2018-10-02 17:34:48 FTS trigger works 1 at a time, but fails with bulk insert script
Previous Message Andreas Kretschmer 2018-10-02 13:52:30 Re: regarding bdr extension