Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1elH06-0003IZ-GV for pgsql-general@arkaria.postgresql.org; Mon, 12 Feb 2018 16:30:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1elH05-00017j-1I for pgsql-general@arkaria.postgresql.org; Mon, 12 Feb 2018 16:30:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1elH04-00017Y-JH for pgsql-general@lists.postgresql.org; Mon, 12 Feb 2018 16:30:40 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1elGzw-0002gp-W6 for pgsql-general@postgresql.org; Mon, 12 Feb 2018 16:30:40 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8072420FD1; Mon, 12 Feb 2018 11:30:31 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Mon, 12 Feb 2018 11:30:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=EPkn4vXvb2zD+6GCm3A6l0kXTvZPz Aa26RmRuFn+Guk=; b=Gq1s+QLwGBJALqg65/49Naj0D6qQiFW8VCMDe0SqfAgT+ t88DDn42hlat7QP6GVMpoozzGJK0NfHktH3VyQfrPjncN7eYvW3bfoWjnywMrCaC Q/2LTSC9GgWom/HV9p4yX3XdA3WjMu4Zcg315ravhz0LowIjFfc1jTAIdkhqGFgR e9EchseFjzu9bZa3abEiwhvD5z9vICeHvWYfJ3McGILNNxPAz25Wz7N8CfH4V6Ld FHVG9q4mi8rSla+3+e/D+4v2qqNw14CxErPszNMwtibo3Qpii3e+JGD3eose/qLw 55MWw2R9HFoQb2NOFVKlKxjnHJNa36SxE11D0rYNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=EPkn4v Xvb2zD+6GCm3A6l0kXTvZPzAa26RmRuFn+Guk=; b=Hs0+zqlKqruLrTmwwCovKl SCCjCayi2fjChCAyvr2mN7nltlXGzqR5H8cgCCRYFbTGDW3ckCfjq6RM1aV++RDt z6bTQ2df5/fr9qSf6oEo4rDEUM9J5kYgxGE+bcSwrNGzk8nfQQCsbmv3zla+T+Uy TcAJ4U7x1KE3hIryKFFw5xsU3/ohc9F88VMVvjWQ5UChS7gGtUjcAKgYLYsP7pJl gDJgTCqGKH0QeIQpnQm3srTl9gUy98/EfnQxS2/a4STmSUmM1mgGIKT+7apZl6f7 5JgLGjL9eXUAYJmFmxs9R+JapUZJkOZndU+QpMaVkIHrTh6lO0xI4Yp2ZCDvcUpg == X-ME-Sender: Received: from [192.168.1.3] (71-212-36-41.tukw.qwest.net [71.212.36.41]) by mail.messagingengine.com (Postfix) with ESMTPA id EF06E248DF; Mon, 12 Feb 2018 11:30:30 -0500 (EST) Subject: Re: execute block like Firebird does To: PegoraroF10 , pgsql-general@postgresql.org References: <1518328644815-0.post@n3.nabble.com> <9fa5f7c2-b6ca-ccfd-fded-284359f973c4@gelassene-pferde.biz> <1518443301602-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: Date: Mon, 12 Feb 2018 08:30:30 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1518443301602-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 02/12/2018 05:48 AM, PegoraroF10 wrote: > We can change all those execute blocks, but it would be a huge work if we > need to rewrite them all. > Today, just for a test, I replaced a Firebird execute block to a Postgres > CTE. OK, worked but I spend 40 minutes and the problem is that we have > hundreds of these execute blocks and on each one we need to rethink, > rewrite, retest. > > When we changed all our triggers and procedures from Firebird to PostGres we > needed only to rewrite "first 1" to "limit 1", "starting with" to "like" as > examples. So, just a Search and Replace will do solve it. > > And now if PostGres doesn´t have something similar to Execute Block we have > to change lots of things. As you may know, change a function body to a CTE > is not so trivial. I do not see a direct correspondence between Execute Block and anything in Postgres. This means one way or another you will be rewriting code. > > 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 ? Why not just return a recordset directly?: https://www.postgresql.org/docs/10/static/plpgsql-overview.html#PLPGSQL-ARGS-RESULTS "PL/pgSQL functions can also be declared to return a “set” (or table) of any data type that can be returned as a single instance. Such a function generates its output by executing RETURN NEXT for each desired element of the result set, or by using RETURN QUERY to output the result of evaluating a query." Evaluating what you are trying to do would be helped by a complete working example of one of your Execute Blocks. > > > > -- > Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html > > -- Adrian Klaver adrian.klaver@aklaver.com