Search Postgresql Archives

Re: Referencing function value inside CASE..WHEN

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

 



Hello

2011/6/19 lover boi <lover-boi@xxxxxxxxxx>:
> Hi,
>
> In the following statement, does the custom function get executed twice?
>
> SELECT
>   MY_FUNCTION(...),
>   CASE WHEN MY_FUNCTION(...) = '...' THEN '...' ELSE '...' END
> ...
> ...
>
>
> If so, is there a way I can make it execute once?  I tried this but it gave
> me a "Column my_function does not exist" error.
>

SELECT x, CASE WHEN x THEN .. ELSE .. END FROM (SELECT fce(..) x FROM foo) s;

Regards

Pavel Stehule

> SELECT
>
>   MY_FUNCTION(...) AS my_function,
>
>   CASE WHEN my_function = '...' THEN '...' ELSE '...' END
>
> ...
>
> ...
>
>
> Thank you in advance.

-- 
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