Decimal problem

Please support our MySQL advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Apr 2008
Posts: 583
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro

Decimal problem

 
0
  #1
Mar 5th, 2009
Hi,
  1. 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
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,787
Reputation: almostbob is a jewel in the rough almostbob is a jewel in the rough almostbob is a jewel in the rough 
Solved Threads: 213
almostbob's Avatar
almostbob almostbob is offline Offline
Posting Virtuoso

Re: Decimal problem

 
0
  #2
Mar 5th, 2009
Originally Posted by veledrom View Post
Hi,
  1. 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)
Last edited by almostbob; Mar 5th, 2009 at 9:47 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 583
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro

Re: Decimal problem

 
0
  #3
Mar 5th, 2009
Understood. Thanks. It works now.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,787
Reputation: almostbob is a jewel in the rough almostbob is a jewel in the rough almostbob is a jewel in the rough 
Solved Threads: 213
almostbob's Avatar
almostbob almostbob is offline Offline
Posting Virtuoso

Re: Decimal problem

 
0
  #4
Mar 5th, 2009
Y'welcome
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 951 | Replies: 3
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC