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!

Decode Statement Inside the Case statement

User_1C9ZRNov 17 2009 — edited Nov 18 2009
Can we use Decode Statement inside a CASE Statement as show below --

It is giving an error -- Is the a better way to write with out any error

create or replace
function test (a varchar2) RETURN VARCHAR2
is
m varchar2(20);
begin
m :=
CASE
WHEN a IN (
'1009' -- (soon obsolete)
,'1010'
,'1019'
,'1051'
,'XGP'
,'XSC')
THEN (SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') into m FROM DUAL)
-- ) THEN '01' -- UNITED STATES OF AMERICA
WHEN a IN (
'1069' -- South Africa
,'SAO' -- South Africa
,'SA' -- South Africa
) THEN '26' -- South Africa

ELSE NULL
END;
return m;
end;
This post has been answered by Frank Kulash on Nov 18 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2009
Added on Nov 17 2009
12 comments
4,618 views