Converting DECODE statement to nested CASE -- need help
470456Nov 8 2006 — edited Nov 8 2006Hi 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;
-----