Re: Using case expressions in update set clause

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: Using case expressions in update set clause
Дата
Msg-id 87sl4csrbe.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Using case expressions in update set clause  ("Chris Velevitch" <chris.velevitch@gmail.com>)
Список pgsql-general
"Chris Velevitch" <chris.velevitch@gmail.com> writes:

> I just want to clarify that the following will always behave the way I
> think it's supposed to behave:-
>
>      update  tableA
>      set       date_field = case when date_field is null then some_date
>                                           else date_field end;
>
> If the current value of date_field for the current record is null then
> set the date_field with some_date value otherwise keep the current
> value of date_field.

That's correct. In this case you could also do it with
 set date_field = coalesce(date_field, some_date)

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Laurent ROCHE
Дата:
Сообщение: Re : Very asynchrnous replication system
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: CHAR SETS