Re: execute block like Firebird does

From: Edson Carlos Ericksson Richter <richter(at)simkorp(dot)com(dot)br>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: execute block like Firebird does
Date: 2018-02-14 13:00:28
Message-ID: d2eec140-e145-6d68-89ac-242db9a79838@simkorp.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Venkateswaran 2018-02-14 13:59:47 Re: Split read/write queries between 2 servers (one master and one slave with streaming replication)?
Previous Message Konstantin Evteev 2018-02-14 11:21:37 Using standby for read-only queries in production and DML operations on primary.