954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Decimal problem

Hi,

INSERT INTO money (salary) VALUES ('100,000,000.00')


100,000,000.00 is stored as 100.00 in decimal (14,2).
I don't know what is wrong?

Thanks

veledrom
Master Poster
758 posts since Apr 2008
Reputation Points: 42
Solved Threads: 0
 

Hi,

INSERT INTO money (salary) VALUES ('100,000,000.00')

100,000,000.00 is stored as 100.00 in decimal (14,2). I don't know what is wrong?

Thanks


do not punctuate numbers in input data
mysql suypports multiple data schema, language-specific and region specific
in many supported schema the comma is a decimal separator, the number is truncated 2 digits after the first valid decimal separator = 100.00
database code is meant to be machine readable, not human readable, so dont try to make it pretty in the database
do any formatting only on output.
number should be 100000000.00.
input validation should strip out any incorrect characters in the input data, and return to the input form for re-entry with a "did you mean" prompt (like google when you mis-spell)
without validation the database wont last very long till it falls over dead
(Likewise repair dates that these salaries refer to, store timestamps not text strings, for the same reasons)

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

Understood. Thanks. It works now.

veledrom
Master Poster
758 posts since Apr 2008
Reputation Points: 42
Solved Threads: 0
 

Y'welcome

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You