SQL Case When Oracle Error code: 932, message: ORA-00932: inconsistent datatypes: expected CHAR got DATE at OCI call OCIStmtExecute. (HY000)

89 views Asked by At

I am a bit new to this and I humbly ask for help to my situation.

CASE        
WHEN '@{LDM}' = 'Lump Only' THEN 'Lump'       
WHEN '@{LDM}' = 'By Day' THEN  "Business Calendar"."Fiscal Date" -- figured issue in this line
ELSE "Gregorian Calendar"."Month" END

I have a problem with my pretty basic code above and can't seem to find a solution anywhere I even experiment with related problems but pathetically I had to give up and try this platform to ask for help.

Result: Error code: 932, message: ORA-00932: inconsistent datatypes: expected CHAR got DATE at OCI call OCIStmtExecute. (HY000)

Above is the result of the code not been acknowledging its content, "Business Calendar"."Fiscal Date" contains date format(YYYY/MM/DD) and "Gregorian Calendar"."Month" contains date format (YYYY/MM)

Expected Result: The date format will be fixed, not resulting in to CHAR/STRING.

Able to figure out the cause and possible solution from this and also to learn, of course. Thank you

1

There are 1 answers

1
Chris On

All cases plus the ELSE must have the same result data type. Since you have "Lump" in there which is a pure string that means that all other possible results must be strings. You have to convert your dates into strings, no matter their date picture.