Referencing function value inside CASE..WHEN

From: lover boi <lover-boi(at)live(dot)co(dot)uk>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Referencing function value inside CASE..WHEN
Date: 2011-06-19 02:45:12
Message-ID: BLU155-W1661F2D893B14654AED26CD56F0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-06-19 02:46:32 Re: fill factor guestimate
Previous Message lover boi 2011-06-19 02:27:23 Referencing function value inside CASE..WHEN