Re: Anonymous code block with parameters

Vik Fearing <vik.fearing@dalibo.com>

From: Vik Fearing <vik.fearing@dalibo.com>
To: Hannu Krosing <hannu@2ndQuadrant.com>, Pavel Stehule <pavel.stehule@gmail.com>, Andres Freund <andres@2ndquadrant.com>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>, Craig Ringer <craig@2ndquadrant.com>, Kalyanov Dmitry <kalyanov.dmitry@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2014-09-18T20:29:02Z
Lists: pgsql-hackers
On 09/18/2014 10:16 PM, Hannu Krosing wrote:
> On 09/18/2014 02:37 PM, Pavel Stehule wrote:
>>
>> if we would to need a "single use" function, then we should to
>> implement it, and we should not to rape some different objects. Some,
>> what has behave like function should be function.
>>
>> After some thinking, probably CTE design can be only one frame, where
>> we can do it
>>
>> WITH
>>          FUNCTION f1(a int) RETURNS int AS $$ .. $$ LANGUAGE plpgsql,
>>          FUNCTION f2(a int) RETURNS SETOF int AS $$ .. $$ LANGUAGE
>> plpgsql,
>>   SELECT f1(x) FROM f2(z) LATERAL ....
>>
>> We can generalize WITH clause, so there SEQENCES, VIEWS, .. can be
>> defined for "single usage"
> +2
> 
> I just proposed the same thing in another branch of this discussion
> before reading this :)
> 
> I guess it proves (a little) that WITH is the right place to do these
> kind of things ...

I've been wanting this syntax for a few years now, so I certainly vote
for it.
-- 
Vik