Re: Evaluate only one CASE WHEN in a select
| От | Guy Rouillier |
|---|---|
| Тема | Re: Evaluate only one CASE WHEN in a select |
| Дата | |
| Msg-id | 4621735E.8040103@burntmail.com обсуждение исходный текст |
| Ответ на | Re: Evaluate only one CASE WHEN in a select ("dcrespo" <dcrespo@gmail.com>) |
| Список | pgsql-general |
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 value into action > field and into number field. Since it's the same function call, I want > it to be run only once and put the above values into their > corresponding fields. My actual function is not that expensive, but > has to be run for every retrieved row, obviously. Does this change > your explanation? If your objective is to run a stored procedure once but return several values, look at either defining multiple OUT parameters, or returning a record type. -- Guy Rouillier
В списке pgsql-general по дате отправления: