pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPostgres 11 procedures and result sets
3+ messages / 3 participants
[nested] [flat]
* Postgres 11 procedures and result sets
@ 2018-10-01 21:53 Jan Kohnert <nospam001-lists@jan-kohnert.de>
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kohnert @ 2018-10-01 21:53 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hello List,
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.
What I found until now is to use inout-Parms. Then I have to define all
columns in the select as inout-Params, but then I get only one line back,
regardless how many lines >0 have been selected.
I could also define an inout refcursor param, and parse that one, but that
would make the new SP identical to the well known functions returning a
refcursor. And when I use that approach, I have an additional step in Qt-Code
for example, since I have to exec the SP, then parse to the refcursor result,
exec the fetch and then parse the cursor output I'm interested in.
Did I miss something?
Thanks in advance!
--
MfG Jan
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Postgres 11 procedures and result sets
@ 2018-10-01 23:57 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jan Kohnert <nospam001-lists@jan-kohnert.de>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2018-10-01 23:57 UTC (permalink / raw)
To: Jan Kohnert <nospam001-lists@jan-kohnert.de>; +Cc: pgsql-general@lists.postgresql.org
Jan Kohnert <nospam001-lists@jan-kohnert.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 :-(
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Postgres 11 procedures and result sets
@ 2018-10-02 16:33 Merlin Moncure <mmoncure@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Merlin Moncure @ 2018-10-02 16:33 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: nospam001-lists@jan-kohnert.de; pgsql-general@lists.postgresql.org
On Mon, Oct 1, 2018 at 6:57 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Jan Kohnert <nospam001-lists@jan-kohnert.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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-10-02 16:33 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 21:53 Postgres 11 procedures and result sets Jan Kohnert <nospam001-lists@jan-kohnert.de>
2018-10-01 23:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-10-02 16:33 ` Merlin Moncure <mmoncure@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox