pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edson Carlos Ericksson Richter <richter@simkorp.com.br>
To: pgsql-general@lists.postgresql.org
Subject: Re: execute block like Firebird does
Date: Wed, 14 Feb 2018 11:00:28 -0200
Message-ID: <d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br> (raw)
In-Reply-To: <1518328644815-0.post@n3.nabble.com>
References: <1518328644815-0.post@n3.nabble.com>

Em 11/02/2018 03:57, PegoraroF10 escreveu:
> 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 ?

Can't you use "with ... select ..."?

Like:

with qry1 as (select bla, bla, bla from xyz), qry2 as (select bla, bla 
from ...)
select * from qry1
union all
select * from qry2


?

Regards,

Edson

-- 
> Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>
>





view thread (23+ messages)  latest in thread

Message-ID: <d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br>
Permalink:  ../d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br/
Also on:    postgresql.org/message-id/d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br

 · 

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: richter@simkorp.com.br
  Subject: Re: execute block like Firebird does
  In-Reply-To: <d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br>
  References: <1518328644815-0.post@n3.nabble.com> <d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br>

* 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