Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting DECODE statement to nested CASE -- need help

470456Nov 8 2006 — edited Nov 8 2006
Hi there!

I am trying to convert DECODE statement to CASE statement.

But i am not sure whether the following DECODE code
is correctly converted to CASE statment.

Need help to write CASE statement and get same results as DECODE does.

---decode

SELECT DECODE(v_ReturnType,'N',v_CAP,'L',DECODE(v_CAP,'1','F',2,'C',3,'X',4,'E'),'S',DECODE(v_CAP,'1','FFS',2,'CAP',3,'CEX',4,'EXT')) ReturnType
INTO v_CAP
FROM DUAL;

---CASE

CASE v_returntype
WHEN 'N' THEN v_cap := v_cap;
CASE v_returntype
WHEN 'L' THEN
CASE v_cap
WHEN '1' THEN v_cap := 'F';
WHEN '2' THEN v_cap := 'C';
WHEN '3' THEN v_cap := 'X';
WHEN '4' THEN v_cap := 'E';
CASE v_returntype
WHEN 'S' THEN
CASE v_cap
WHEN '1' THEN v_cap := 'FFS';
WHEN '2' THEN v_cap := 'CAP';
WHEN '3' THEN v_cap := 'CEX';
WHEN '4' THEN v_cap := 'EXT';
END CASE;
END CASE;
END CASE;
END CASE;
END CASE;

-----
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2006
Added on Nov 8 2006
3 comments
853 views