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!

I am trying to write a case statement which has If then clause. I keep getting error "Missing keywor

user5131783Jan 30 2015 — edited Feb 3 2015


The Case statement with if clause

If REC_STAT_CD in ('B' , 'J')

   if ACB_CD in  (NA, A, B,C, D, Z,V,W,X,Y,S) or CONS_INF_IND in (NA, A, B,C, D, Z,V,W,X,Y,S)
  Then 'Active'
  Else 'Disch'
endif

Else (not B and not J)
'None'
endif

Table are Table XYZ. My query is as below:

select

CASE WHEN REC_STAT_CD in ('B','J') then

          CASE when ACB_CD in  ('NA', 'A', 'B','C', 'D', 'Z','V','W','X','Y','S') or CONS_INF_IND in ('NA', 'A', 'B','C', 'D', 'Z','V','W','Y','S') 

          then 'Active' else 'Disch'

          END)

END)

CASE when REC_STAT_CD not in ('B','J') then 'None'

END)

from LDS.XYZ

My query works fine if I remove the 2nd case statement , but I am not sure how else can i put the clauses in the query. I need the entire output for one column  REC_STAT_CD. Please provide inputs , any help truly appreciated.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2015
Added on Jan 30 2015
5 comments
1,239 views