By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,660 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,660 IT Pros & Developers. It's quick & easy.

Oracle decode Function in Postgres

P: n/a
Hi,
Like I see there is no equivalent to the Oracle decode Function
In Postgres.Is there maybe somebody who wrote decode as a
Function?

Schoeib

4Tek Gesellschaft fr angewandte Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de
Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Of course there is an equivalent: the case construct.
There is some nice documentation about the available functions and
operators at:
http://www.postgresql.org/docs/view....functions.html
and specifically for CASE:
http://www.postgresql.org/docs/view....l.html#AEN9698
You might also find useful to know that the NVL oracle function's
parallel in postgres is COALESCE.

HTH,
Csaba.

On Wed, 2003-09-03 at 11:00, Amin Schoeib wrote:
Hi,
Like I see there is no equivalent to the Oracle decode Function
In Postgres.Is there maybe somebody who wrote decode as a
Function?

Schoeib

4Tek Gesellschaft für angewandte Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #2

P: n/a
--- Amin Schoeib <as******@4tek.de> wrote:
Hi,
Like I see there is no equivalent to the Oracle
decode Function
In Postgres.Is there maybe somebody who wrote decode
as a
Function?
The problem for any such body is that there is no one
function possible in PostgreSQL that will cover all of
the possible use cases of "decode" in Oracle. As I
understand things, "decode" takes a variable number of
arguments, for a variety of datatypes. In PostgreSQL
you would need to create a separate "decode" function
for every distinct set of arguments (number and
datatypes) that you are likely to encounter. That
would be a lot of work for a generalized case.

You may be best served by searching your code for
usage of "decode", and writing only those versions
that you need. The coding for each one would be
trivial, using "case" constructions.

Schoeib

4Tek Gesellschaft fr angewandte
Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.