From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | PegoraroF10 <marcos(at)f10(dot)com(dot)br> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: execute block like Firebird does |
Date: | 2018-02-12 16:48:47 |
Message-ID: | CAKFQuwaw7k84orwmvh_C+920NfSLiuZ9d2VUQMEyM2RURx3atg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Feb 12, 2018 at 6:48 AM, PegoraroF10 <marcos(at)f10(dot)com(dot)br> wrote:
> Another approach to solve my problem would be a function that receives a
> dynamic SQL, runs it and returns a XML or JSON and on client side I convert
> that XML back to a recordset. Is that possible ?
Yes, you can pass "text" SQL into a pl/pgsql function and "EXECUTE" it.
That text must be plain SQL though, not pl/pgsql.
Converting pl/pgsql into plain SQL and executing it as a CTE seems like an
over-solution. What should be reasonably possible to rewrite the "execute
block" as a "create function" then modify your clients to do send "select *
from function();" instead of "execute block ..."
If I was you I'd even be curious enough to see if maybe there is an
external third-party extension "pl/firebase" language out there which would
let you comfortably copy-paste the block text into the function body with
minimal or no editing.
David J.
p.s. reading PostGres is hard on our (mine at least) eyes. Its either
Postgres, or PostgreSQL - neither with a capital G.
From | Date | Subject | |
---|---|---|---|
Next Message | PegoraroF10 | 2018-02-12 16:57:05 | Re: execute block like Firebird does |
Previous Message | Adrian Klaver | 2018-02-12 16:30:30 | Re: execute block like Firebird does |