Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: help with decode

Re: help with decode

From: Serge Rielau <srielau_at_ca.ibm.com>
Date: Wed, 03 Aug 2005 10:47:18 -0400
Message-ID: <3lc3npF11tmbtU1@individual.net>


soup_or_power_at_yahoo.com wrote:
> SELECT (DECODE(a1, 'b1', a2, 'b2')) from A
==
SELECT CASE a1 WHEN 'b1' THEN a2 ELSE 'b2' END FROM A
>
> SELECT (DECODE(a1, 'b1 || a2, 'b2')) from A
==
SELECT CASE a1 WHEN 'b1' || a2 THEN 'b2' ELSE NULL END FROM A or
SELECT CASE a1 WHEN CONCAT('b1', a2) THEN 'b2' ELSE NULL END FROM A

DECODE is a shorthand for CASE. Shorthands can be crypric :-)

|| is the infix notation for CONCAT. Just like + is an infix notation for an (imaginary) function PLUS(arg1, arg2)

> Also if I use CHR(1) as follows what does it mean?
>
> SELECT (DECODE(a1, 'b1 || CHR(1) || a2, 'b2')) from A
*Ehem* Now you're way off topic and I'm quite certain that your docs have a description of the CHR() function.

Cheers
Serge

-- 
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Received on Wed Aug 03 2005 - 09:47:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US