Forum OpenACS Q&A: Re: AOLserver 3.5.1

Collapse
7: Re: AOLserver 3.5.1 (response to 5)
Posted by Richard Hamilton on
A search for decode in the ACS site search did not reveal anything but google came up with this which is in fact at : http://sdm.openacs.org/doc/openacs/html/oracle-to-pg-porting.html

Decode

Oracle's handy decode function works as follows:
decode(expr, search, expr[, search, expr...] [, default])
To evaluate this expression, Oracle compares expr to each search value one by one. If expr is equal to a search, Oracle returns the corresponding result. If no match is found, Oracle returns default, or, if default is omitted, returns null.
Postgres doesn't have the same construct. It can be replicated with:
CASE WHEN expr THEN expr [...] ELSE expr END
which returns the expression corresponding to the first true predicate.
For example:
CASE WHEN c1 = 1 THEN 'match' ELSE 'no match' END
_______________________________________

I assume that the decode function that has been defined in postgres and that I have mentioned above takes care of the issue? Can anyone confirm that?