Re: Porting Oracle Decode to Postgresql

Поиск
Список
Период
Сортировка
От Tod McQuillin
Тема Re: Porting Oracle Decode to Postgresql
Дата
Msg-id 20011122184250.G20207-100000@glass.pun-pun.prv
обсуждение исходный текст
Ответ на Porting Oracle Decode to Postgresql  (MindTerm <mindterm@yahoo.com>)
Ответы Re: Porting Oracle Decode to Postgresql  (MindTerm <mindterm@yahoo.com>)
Список pgsql-sql
On Thu, 22 Nov 2001, MindTerm wrote:

>   I am writing to ask how to port oracle's decode( ..)
> function to postgresql ?

The ANSI SQL version of decode is CASE.

See http://www.postgresql.org/idocs/index.php?functions-conditional.html
for the full documentation, but basically, it works like this:

Oracle:
decode (value, 0, 'zero', 1, 'one', 'unknown')

ANSI:
CASE WHEN value=0 THEN 'zero' WHEN value=1 THEN 'one' ELSE 'unknown' END

or

CASE value WHEN 0 THEN 'zero' WHEN 1 THEN 'one' ELSE 'unknown' END

-- 
Tod McQuillin




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

Предыдущее
От: MindTerm
Дата:
Сообщение: Porting Oracle Decode to Postgresql
Следующее
От: MindTerm
Дата:
Сообщение: Re: Porting Oracle Decode to Postgresql