Re: [GENERAL] Evaluate only one CASE WHEN in a select

2007-04-14 Thread Guy Rouillier
dcrespo wrote: SELECT CASE WHEN is_odd(t.number) THEN 'Update' ELSE 'Insert' END AS action, CASE WHEN is_odd(t.number) THEN t.number ELSE NULL END AS number, FROM ... ; As you can see, is_odd function (only a function example) is being run twice with exactly the same parameters to put a

Re: [GENERAL] Evaluate only one CASE WHEN in a select

2007-04-13 Thread dcrespo
On Apr 12, 4:30 pm, [EMAIL PROTECTED] (Tom Lane) wrote: > "dcrespo" <[EMAIL PROTECTED]> writes: > > They are exactly the same, that's why I want to evaluate it only once > > and, depending on it, put the corresponding value into two different > > fields that must be returned, instead of evaluating

Re: [GENERAL] Evaluate only one CASE WHEN in a select

2007-04-12 Thread Tom Lane
"dcrespo" <[EMAIL PROTECTED]> writes: > They are exactly the same, that's why I want to evaluate it only once > and, depending on it, put the corresponding value into two different > fields that must be returned, instead of evaluating once for each > field. Any insight? There's no solution that wo

Re: [GENERAL] Evaluate only one CASE WHEN in a select

2007-04-12 Thread dcrespo
On Apr 11, 11:35 pm, [EMAIL PROTECTED] (Guy Rouillier) wrote: > dcrespo wrote: > > Hi everybody, > > > I'm implementing something like this: > > > SELECT > > CASE WHEN add_numbers(t1.main_number,t2.main_number)>100 > > THEN t1.description1 > > ELSE t2.description1 > > END AS

Re: [GENERAL] Evaluate only one CASE WHEN in a select

2007-04-11 Thread Guy Rouillier
dcrespo wrote: Hi everybody, I'm implementing something like this: SELECT CASE WHEN add_numbers(t1.main_number,t2.main_number)>100 THEN t1.description1 ELSE t2.description1 END AS number_description1, CASE WHEN add_numbers(t1.main_number,t2.main_number)>100 T

[GENERAL] Evaluate only one CASE WHEN in a select

2007-04-11 Thread dcrespo
Hi everybody, I'm implementing something like this: SELECT CASE WHEN add_numbers(t1.main_number,t2.main_number)>100 THEN t1.description1 ELSE t2.description1 END AS number_description1, CASE WHEN add_numbers(t1.main_number,t2.main_number)>100 THEN t1.descriptio