Search Postgresql Archives

Re: Functions as first-class values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2011/4/6 Jon Smark <jon.smark@xxxxxxxxx>:
> Hi,
>
> Is there support in PL/pgSQL for treating functions as first-class values?
> Consider the pseudo-code simple example below, which illustrates how this
> feature can be useful. ÂI reckon that this behaviour can be emulated using
> EXECUTE, but I suspect there are serious performance penalties.
> Your thoughts?
>
> Thanks in advance!
> Jon
>
>
> CREATE FUNCTION f1 (int) RETURNS boolean ...
> CREATE FUNCTION f2 (int) RETURNS boolean ...
> CREATE FUNCTION f3 (int) RETURNS boolean ...
>
> CREATE FUNCTION do_stuff ...
> BEGIN
> Â Â Â ÂCASE cond
> Â Â Â Â Â Â Â ÂWHEN 'a' THEN func := f1;
> Â Â Â Â Â Â Â ÂWHEN 'b' THEN func := f2;
> Â Â Â Â Â Â Â ÂWHEN 'c' THEN func := f3;
> Â Â Â ÂEND CASE
>
> Â Â Â ÂSELECT * FROM foobar WHERE func (foobar.age);
> END;
>

no it isn't possible.

Regards

Pavel Stehule



>
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux