[thelist] [SQL] Case vs Decode

Luther, Ron Ron.Luther at hp.com
Tue Mar 4 08:02:02 CST 2003


Mark M asked:

>>Just as a matter of interest - anyone know of any articles / have any comments
>>on when and where it is better to use a CASE statement, as opposed to DECODE?
>>(I'm using Oracle... in case you wondered)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Hi Mark,

I'll agree with Rudy on both points; (1) DECODE is probably an 'older' Oracle
function than CASE, (2) for hand-coding CASE is most likely a better and more
flexible way to go.

This is just a little side note to point out that many/most/all(?) of the
'business intelligence' enterprise report writer tools that Intranet
analysis folks would run into, {Brio, Business Objects, etc.}, are going
to have DECODE available as a built-in point-and-drool accessible function
when you are working with an Oracle database. These tools will not
[explicitly] offer the CASE function - probably because of the more
complicated syntax. (Sometimes though, they _do_ give you ways to get around
that.)

So that's one place where you can run into a fair amount of use of the
DECODE function.


HTH,

RonL.




More information about the thelist mailing list