Wednesday, 21 August 2013

Data truncated for column 'x'

Data truncated for column 'x'

I am trying to get the distance between two points, that works fine, but
what I am having issues with is are these warning messages:
Data truncated for column 'x' at row 32
Data truncated for column 'x' at row 82
Data truncated for column 'x' at row 89
This is the function I have created:
CREATE FUNCTION `GetDistance`(`lat1` numeric(10, 7), `lon1` numeric(10,
7), `lat2` numeric(10, 7), `lon2` numeric(10, 7))
RETURNS decimal(10,7)
BEGIN
DECLARE x decimal(10, 7);
DECLARE pi decimal(21, 20);
SET pi = 3.14159265358979323846;
SET x = round(sin(lat1 * pi / 180)
* sin(lat2 * pi / 180)
+ cos(lat1 * pi / 180)
* cos(lat2 * pi / 180)
* cos((lon2 * pi / 180) - (lon1 * pi / 180)), 7);
SET x = round(atan((sqrt( 1- power( x, 2))) / x), 7);
RETURN round((1.852 * 60.0 * ((x / pi) * 180)) / 1.609344, 7);
END
Here are the two columns for lat1, lon1 and lat2, lon2
CREATE TABLE `world_cities` (
`latitude` DECIMAL(10,7) NULL DEFAULT NULL,
`longitude` DECIMAL(10,7) NULL DEFAULT NULL,
)
So, what is causing this warning message?

No comments:

Post a Comment