Re: Referencing function value inside CASE..WHEN - Mailing list pgsql-general

From David Johnston
Subject Re: Referencing function value inside CASE..WHEN
Date
Msg-id AA299BBF-8E7E-443F-86C1-DABF23C5DDC9@yahoo.com
Whole thread Raw
In response to Referencing function value inside CASE..WHEN  (lover boi <lover-boi@live.co.uk>)
List pgsql-general
You can try using a CTE/With clause.  Failing that use a function with SELECT INTO...

On Jun 18, 2011, at 22:45, lover boi <lover-boi@live.co.uk> wrote:

> 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
>
>   MY_FUNCTION(...) AS my_function,
>
>   CASE WHEN my_function = '...' THEN '...' ELSE '...' END
>
> ...
>
> ...
>
>
> Thank you in advance.

pgsql-general by date:

Previous
From: David Resnick
Date:
Subject: Port forwarding via iptables to postgres listening locally
Next
From: Daron Ryan
Date:
Subject: Re: Search for lists