| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | Urgent MySQL issue - will pay $25 for a solution Hi all I HAVE AN URGENT ISSUE!! I have a database table where I am storing VERY large numbers.... numbers up to 200 digits long. I had this working on my MySQL 4 database but we migrated to MySQL 5.0.27 this week and I am having issues. I have a field set to DOUBLE(200,0). When I try and insert/update a large number like 99999999999999999999999999999999999999999999999999 999999999999999999999999999 I check the data and it is "truncated" to: 9999999999999999635896294965248 for example: Code: insert into test (val) values ('99999999999999999999999999999999999999999999999999999999999999999999999999999') ????: NamePros.com http://www.namepros.com/programming/320554-urgent-mysql-issue-will-pay-25-a.html Then i do a select and I get: Code: select * from test; val --- 9999999999999999635896294965248 I dont know why at the moment..... its not PHP as I access another database running off the same web server that works, its got to do with this new version of MySQL 5. Our SQL MODE is set to '' When I run an update and try update the column with the large number we get the warning: Warning | 1264 | Out of range value adjusted for column 'money' at row 1 Can anyone help? Its pretty URGENT!!!!
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #2 (permalink) | ||||
| fka: leonardo Join Date: Aug 2006
Posts: 736
![]() ![]() ![]() ![]() ![]() |
The behaviour of doubles/floats is platform-dependant. But what is more important is doubles are only approximates, so having a double with 0 decimals does not make sense. If you really need integers this huge you should build a custom solution. I recommend storing them as a text-type in your database and cast them to something that can be treated as an integer in your software/scripts. This is probably not supported in the programming/scripting language you are using so you should find a library supporting integers this big represented in strings or build it yourself, or hire someone to build it for you. | ||||
| |
| | THREAD STARTER #3 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | I realise they are approximates but thats ok for what I am using them for. Like I said I had this working on the previous MySQL version we were running.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #4 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | HERE'S THE $25 FIX: change the column type from DOUBLE(200,0) to DECIMAL(200,0) When you upgrade past 5.0.3, go back to DOUBLE. From http://dev.mysql.com/doc/refman/5.0/...-overview.html : PHP Code: |
| |
| | THREAD STARTER #5 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | DECIMAL(200) will not work in 5.0.27, it is limited to 65 digits. I have already tried this. And yes I know exactly how all the numeric datatypes are supposed to behave.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #6 (permalink) | ||||
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=320554 According to the MySQL docs that I posted, before 5.0.3, DECIMAL can have more than 65 digits... stored as an unpacked fixed-point number. I misread you as upgrading to 5.0.2, not 5.0.27. Here's the relevant article: http://dev.mysql.com/doc/refman/5.0/...l-changes.html The real answer here is to convert the large number into a float first, and then insert it. Please keep the $25. | ||||
| |
| | THREAD STARTER #7 (permalink) | ||||
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | I really appreciate the help/assistance beleive me! This thing is driving me nuts! ????: NamePros.com http://www.namepros.com/showthread.php?t=320554
Dude if you help me get this running you'll get $25, I'm a man of my word.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire | ||||
| |
| | THREAD STARTER #9 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | Yep have read that Steve.... everything in there suggests what I am doing should work as it does in Ver 4.0.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #10 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | No, Dan, the link I linked to says that as of 5.0.3, inserting a number that large doesn't work anymore for DECIMAL or DOUBLE. Try a few things here: First, try using the FLOAT numeric type instead of DECIMAL or DOUBLE. As of 5.0.3, it's the only numeric type that can represent integers with more than 65 digits. ????: NamePros.com http://www.namepros.com/showthread.php?t=320554 Second, in your SQL, you have: Code: insert into test (val) values ('99999999999999999999999999999999999999999999999999999999999999999999999999999') Code: insert into test (val) values (99999999999999999999999999999999999999999999999999999999999999999999999999999) |
| |
| | THREAD STARTER #11 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | OK i tried using a FLOAT(200,0) and it capped it at 9999999848243207295109594873856 Similar issue.... Getting rid of the quotes had no effect. I have submitted a bug to mySQL so hopefully the developers can sort it out.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #12 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | No, Dan, you gotta use FLOAT with no argument... test this out: Code: CREATE TABLE `test` ( `test` FLOAT NOT NULL , `test2` FLOAT( 200, 0 ) NOT NULL ) ENGINE = MYISAM ; |
| |
| | THREAD STARTER #13 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | OK tried that... but then its stored like 3.40282e+38 Not really want I am after.... I dont understand why it cant work as it did in the previous version. What are people supposed to do that need it to work that way and have built whole applications relying on it.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #14 (permalink) | ||||
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | Well, really, 3.40282e+38 is the proper representation in this case. If you need it to store the plain text integer version, use VARCHAR or TEXT, however arithmetic operations won't work on them. ????: NamePros.com http://www.namepros.com/showthread.php?t=320554
If you need to do math but still maintain the exact integer, use two columns... one that is the text representation, and one that is the float representation. Ahh, the wonderful world of migrating code. | ||||
| |
| | THREAD STARTER #15 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | Well thats going to be a massive pain because I have MANY fields like this... MANY. arrrrrggghhhhhhh Probably easier to stay at this version of MySQL than migrate this application to the next version.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | #16 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | I believe that unless you need or desire features of higher versions, then there is no reason to upgrade to a newer version. I use MySQL 4.X for most of my apps... but one of my clients needed a MySQL cluster, a feature that works much better in 5.0.X. Migrate when it's appealing to do so, not when it's available to do so. |
| |
| | THREAD STARTER #17 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | Agree for sure but I have other applications where I need the new version so it was easier to migrate all of my applications as I have one database server. In saying that MySQL 5 does have new features I would like to take advantage of anyway like views, stored procedures, triggers etc
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
| | THREAD STARTER #19 (permalink) |
| AdToll.com Join Date: Feb 2006 Location: Perth, WA
Posts: 256
![]() ![]() | hahaha yes the "solution".... like I said I have submitted a bug report so will be interesting to see what the developers say. I will post up the feedback here.
__________________ AdToll.com : 75% share : 20%-Adv. 10%-Pub. Aff. profit share : Text, Banner, Video & Peel Away : Paypal, Check, Wire |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |