pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Regarding decode function
2+ messages / 2 participants
[nested] [flat]

* Regarding decode function
@ 2003-10-01 22:43  Buchi_Babu@cymer.com
  0 siblings, 1 reply; 2+ messages in thread

From: Buchi_Babu@cymer.com @ 2003-10-01 22:43 UTC (permalink / raw)
  To: pgsql-sql

Hi All,
 
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.
 
Thanks in advance for your great help.
 
Thanks
Babu Mannem 
 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Regarding decode function
@ 2003-10-04 00:50  Doris Bernloehr <bedo7@gmx.net>
  parent: Buchi_Babu@cymer.com
  0 siblings, 0 replies; 2+ messages in thread

From: Doris Bernloehr @ 2003-10-04 00:50 UTC (permalink / raw)
  To: 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-10-04 00:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 22:43 Regarding decode function Buchi_Babu@cymer.com
2003-10-04 00:50 ` Doris Bernloehr <bedo7@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox