Re: Any reasons for 'DO' statement not returning result?

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Xtra Coder <xtracoder(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Any reasons for 'DO' statement not returning result?
Date: 2016-08-10 23:18:45
Message-ID: 76a7122c-24e6-e2c3-be97-275f9d0fe695@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/8/16 7:25 PM, Xtra Coder wrote:
> 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?

I don't recall why DO was designed that way, but I created
http://pgxn.org/dist/pg_lambda/ to do what you're looking for.
Unfortunately it's not quite as convenient as DO, and you also must
ALWAYS provide at least one correctly typed input (even if it's NULL) so
the pseudotype will work.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532) mobile: 512-569-9461

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2016-08-10 23:34:10 Re: Jsonb extraction very slow
Previous Message Tom Lane 2016-08-10 22:56:27 Re: plpython.h not installed in 9.4