pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <andreas@a-kretschmer.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: execute block like Firebird does
Date: Sun, 11 Feb 2018 09:46:38 +0100
Message-ID: <ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de> (raw)
In-Reply-To: <1518328644815-0.post@n3.nabble.com>
References: <1518328644815-0.post@n3.nabble.com>



Am 11.02.2018 um 06:57 schrieb PegoraroF10:
> We are migrating our databases from Firebird to PostGres. A useful feature
> Firebird has is Execute Block.
> What it does is just return a record set from that dynamic SQL, just like a
> PostGres function, but without creating it.
> It sound like ...
> execute block returns(ID Integer, Name varchar(50), LastInvoice Date, ...)
> as
> begin
>    select bla, bla, bla into ...;
>    select bla, bla into ...;
>    suspend;
> end
> I know we could create a function but we have several hundred of these
> blocks running, so ... it would be a huge work to do.
> So, there is a way to run a dynamic sql which returns a set of records ?

you can use a DO - block:


https://www.postgresql.org/docs/current/static/sql-do.html


Regards, Andreas

-- 
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com





view thread (23+ messages)  latest in thread

Message-ID: <ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de>
Permalink:  ../ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de/
Also on:    postgresql.org/message-id/ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andreas@a-kretschmer.de
  Subject: Re: execute block like Firebird does
  In-Reply-To: <ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de>
  References: <1518328644815-0.post@n3.nabble.com> <ecd15713-94c2-7532-b5cf-b448cd9bb652@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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