Re: Functions as first-class values

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Functions as first-class values
Дата
Msg-id BANLkTimQrFHifQ9=th6HMp85Vhy4dd6Oug@mail.gmail.com
обсуждение исходный текст
Ответ на Functions as first-class values  (Jon Smark <jon.smark@yahoo.com>)
Ответы Re: Functions as first-class values
Список pgsql-general
Hello

2011/4/6 Jon Smark <jon.smark@yahoo.com>:
> 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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: forums.postgresql.com.au
Следующее
От: "Davenport, Julie"
Дата:
Сообщение: temp tables not dropping at end of script