Re: Regarding decode function - Mailing list pgsql-sql

From Doris Bernloehr
Subject Re: Regarding decode function
Date
Msg-id 3F7E1946.3060604@gmx.net
Whole thread Raw
In response to Regarding decode function  (Buchi_Babu@cymer.com)
List pgsql-sql
> Right now I have a query which uses decode function to get data in 
> Oracle database, I want know is there any alternative function to 
> decode which can do the decode functionality in Postgresql.

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

In PostgreSQL you have to use CASE WHEN Syntax:

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

Regards
Doris



pgsql-sql by date:

Previous
From: Wei Weng
Date:
Subject: function with variable length of parameters
Next
From: ow
Date:
Subject: FK Constraints, indexes and performance