Re: execute block like Firebird does - Mailing list pgsql-general

From David G. Johnston
Subject Re: execute block like Firebird does
Date
Msg-id CAKFQuwaw7k84orwmvh_C+920NfSLiuZ9d2VUQMEyM2RURx3atg@mail.gmail.com
Whole thread Raw
In response to Re: execute block like Firebird does  (PegoraroF10 <marcos@f10.com.br>)
List pgsql-general
On Mon, Feb 12, 2018 at 6:48 AM, PegoraroF10 <marcos@f10.com.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.​

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: execute block like Firebird does
Next
From: PegoraroF10
Date:
Subject: Re: execute block like Firebird does