Question Locked

Oracle CASE missing keyword error ?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

When trying to run a piece of code I get ora-00905 missing keyword
I marked the line that gives thw error. Thanks

code:
(CASE
WHEN (EOQ) - ((CASE ps.payment_schedule_date
When '00000000'
then TO_DATE(To_NUMBER(pl.pledge_year_of_giving + 5)||'0630','YYYY/MM/DD')
Else TO_DATE(ps.payment_schedule_date,'YYYY/MM/DD')
end)) < to_char(180) THEN
-- ++++++++++++++++++++++++++++++ ERROR HERE
round(ps.payment_schedule_balance*(pl.pledge_amount/pp.prim_pledge_amount),12) amount
END ) 'Current' ,
(CASE
WHEN (EOQ) - ((CASE ps.payment_schedule_date
When '00000000'
then TO_DATE(To_NUMBER(pl.pledge_year_of_giving + 5)||'0630','YYYY/MM/DD')
Else TO_DATE(ps.payment_schedule_date,'YYYY/MM/DD')

end)) between to_char(180) and to_char(365)then ' 6 months - 1 Yr Past Due'
END ),
(CASE
WHEN (EOQ) - ((CASE ps.payment_schedule_date
When '00000000'
then TO_DATE(To_NUMBER(pl.pledge_year_of_giving + 5)||'0630','YYYY/MM/DD')
Else TO_DATE(ps.payment_schedule_date,'YYYY/MM/DD')
end)) between to_char(366) and to_char(730) THEN '1 Yr - 2 Yrs Past Due'
END) ,
(CASE
WHEN (EOQ ) - ((CASE ps.payment_schedule_date
When '00000000'
then TO_DATE(To_NUMBER(pl.pledge_year_of_giving + 5)||'0630','YYYY/MM/DD')
Else TO_DATE(ps.payment_schedule_date,'YYYY/MM/DD')
end)) > to_char(730) THEN '2 Yrs - 3 Yrs Past Due'
END)

3 replies

by robo_dev

have you nested the correct number of parenthethes?

Remember a case statement stops at the first true statement.

Typically a missing 'end' causes that error. So I am not sure the "< to_char(180) THEN" after the end is syntactically consistent.

by tony hopkinson

Same place as Robodev.
Where you have two befiore the inner case and two after it's end, redundant or wrong...
You might want to have a look at some functions for this, wold nake it much more readable and therefore maintainable.

This discussion is closed to new replies.