Re: Porting Oracle Decode to Postgresql - Mailing list pgsql-sql

From Tod McQuillin
Subject Re: Porting Oracle Decode to Postgresql
Date
Msg-id 20011122184250.G20207-100000@glass.pun-pun.prv
Whole thread Raw
In response to Porting Oracle Decode to Postgresql  (MindTerm <mindterm@yahoo.com>)
Responses Re: Porting Oracle Decode to Postgresql
List 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 by date:

Previous
From: MindTerm
Date:
Subject: Porting Oracle Decode to Postgresql
Next
From: MindTerm
Date:
Subject: Re: Porting Oracle Decode to Postgresql