I am having a database column amount [Data type Number(32,12)]
.When i use to_char
on the amount
field i get a slash value appended in the output.
When i directly used the value stored in the amount field ,i am getting the correct value
select TO_Char(0.000000000099,'FM99999999999999999999999999999990.099999999999') from dual;
Output:-
0.000000000099
It looks like you have corrupted data in your table. Which leads to a few questions including how did it get there, and what can you do about it?
Corrupt numeric (or date) values often come from OCI programs, but there are some bug reports that suggest
imp
has been known to cause corruption. The internal representation is documented in support note 1007641.6, but I find something like this explanation easier to work with when recreating problems, and using a PL/SQL block is possible in place of an OCI program.The two numbers you're having problems with should be represented internally like this:
I haven't figured out exactly what values you have in your table, but I can show a similar result:
Dumping the values shows they look a bit odd:
Running your formatting against that gives similar results:
If you can add the
dump()
output for your own data to the question then I can see if I can recreate exactly the values you're seeing.Anecdotally, it might be possible to 'correct' this by updating the data, e.g.:
However, you have to ask what the actual correct value is, which probably comes back to how/why/when it was corrupted. I would be very wary of touching this data if it is at all important, and would really have to second @DazzaL's advice to get Oracle Support involved to sort it out.