Any reasons for 'DO' statement not returning result?

From: Xtra Coder <xtracoder(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Any reasons for 'DO' statement not returning result?
Date: 2016-08-09 00:25:40
Message-ID: CAL2enjJinzk_UZbTU3bRNBYuox9dn+LbzD0sBeu4v7vjrSeaag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm just curious about the reasons of the design of 'DO' statement so that
it is not able to return result of the SELECT in its body.

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

http://stackoverflow.com/questions/14652477/how-to-perform-a-select-query-in-a-do-block

With some former experience with MsSQL server, where 'complex' script is
executed easily and straightforward without any 'wrapping', like this
dummy-one ...

DECLARE @a int;
DECLARE @b int;
...
select @a + @b as "a+b"

... every time I need to execute some one-time-through-away complex code in
PostgreSQL which returns rowset I'm disappointed - this has to be wrapped
into normal 'temp' function which I have to delete all the time in current
session, thus making an anonymous 'DO' statement use-less in 95% of my
use-cases.

So ... may someone know good reasons for such inconvenient design of 'DO'
statement?

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Venkata Balaji N 2016-08-09 02:47:21 Re: Logical Decoding Failover
Previous Message Tom Lane 2016-08-08 23:18:13 Re: select array_remove(ARRAY[NULL,NULL,NULL],NULL); returns {} instead of {NULL,NULL,NULL}