Skip to content
Advertisement

Out of Range Error while inserting into a MySQL decimal column

I have this tabular structure:

enter image description here

I get an error when i try to insert a specific set of value, query with those values is as below:

enter image description here

For longitude with value -161.9722021 it is throwing me an error, values less than 100 value were successfully inserted. I don’t see the value being out of range, the value i am giving in the query is not a string and is a decimal value as specified. I have checked other similar questions on the internet, but they actually had a value out of range. I am still unable to figure out why I am getting this error.

Advertisement

Answer

decimal(10,8) means that you have ten digits, and eight of those are for the decimal part.

This leaves two digits only for the integer part.

And that is why “values less than 100 are successfully inserted” — because their integer part only takes two digits.

Use either DECIMAL(11,8) (same precision) or DECIMAL(11,7) (same size).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement