Using case in an update statement ?

Поиск
Список
Период
Сортировка
От Peter Alberer
Тема Using case in an update statement ?
Дата
Msg-id 001001c20bd0$d0566060$5be0d089@ekelhardt
обсуждение исходный текст
Ответы Re: Using case in an update statement ?
Re: Using case in an update statement ?
Список pgsql-novice

Hi,

 

I would like to change some rows in a table to two different values depending on the current value.

The value of the column “status” should be changed to ''CLOSED_SUCC'' when its current value is ''OPEN_SUCC'' and it should be ''CLOSED_FAIL'' when the current value is ''OPEN_FAIL''. Of course I could write two statements, but can it be done in one statement ?

 

I tried to do it with “case” but that failed.

 

update lr_object_usage set status = (case when status = ''OPEN_SUCC'' then ''CLOSED_SUCC'' when status = ''OPEN_FAIL'' then ''CLOSED_FAIL'');

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

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: date conversions
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: Using case in an update statement ?