Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: help with decode
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 LabReceived on Wed Aug 03 2005 - 09:47:18 CDT
![]() |
![]() |