ORA-00932: inconsistant data types: expect CHAR got NUMBER

Carscomp

New Member
Joined
Oct 21, 2014
Messages
10
With this case when statement i get the above error. I no the the Sales Order is the issue, but i have not been able to figure this out.
in the data base the TOP_LEVEL_DEMAND_TYPE is formatted as NUMBER(10)

case when TOP_LEVEL_DEMAND_TYPE = '-6'
then ("Sale Order") else TOP_LEVEL_DEMAND_TYPE
end case
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
What program are you doing this in?
You posted it in the Excel Questions forum, but it does not look like Excel VBA code to me.
 
Upvote 0
Excel SQL is where the code is in
OK. For future reference, be sure to mention that in your post so people know where you are trying to do this.

Knowing what I know about SQL, if TOP_LEVEL_DEMAND_TYPE is indeed formatted to be a number, then this line:
Rich (BB code):
case when TOP_LEVEL_DEMAND_TYPE = '-6'
probably needs to look like this:
Rich (BB code):
case when TOP_LEVEL_DEMAND_TYPE = -6
as single and double quotes are used to designate Text entries, not Numeric ones.
Numeric entries should NOT have any quotes around them.
 
Upvote 0
It's probably the double quotes around "Sale Order" as well.
Rich (BB code):
case
    when TOP_LEVEL_DEMAND_TYPE = '-6' then 'Sale Order'
    else TOP_LEVEL_DEMAND_TYPE
end
 
Upvote 0
It's probably the double quotes around "Sale Order" as well.
Rich (BB code):
case
    when TOP_LEVEL_DEMAND_TYPE = '-6' then 'Sale Order'
    else TOP_LEVEL_DEMAND_TYPE
end
Thanks for your help. I still get the same error. I don't understand why though. If i remove the wording 'Sale Order' and place a number (1 for example) there, it places that value on the sheet. I just have not been able to figure out a work around for replacing a number with 'Sale Order'. I have tried to_char('Sale Order') and still get the same error.
I am using excel 365 64 bit if that helps.
 
Upvote 0
Did you see my reply?
Try removing the quotes from around -6 too!
 
Upvote 0
Hi, it looks like you a trying to query an Oracle database, if that's the case you can try like this:

Rich (BB code):
case
    when TOP_LEVEL_DEMAND_TYPE = -6 then 'Sale Order'
    else TO_CHAR(TOP_LEVEL_DEMAND_TYPE)
end

All the values returned by the case statement need to be of the same type.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,845
Messages
6,181,298
Members
453,030
Latest member
PG626

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top