MySQL 1265数据截断列 - 消息没有意义

时间:2017-11-24 01:15:41

标签: mysql

我不清楚为什么在运行对十进制值进行计算(使用函数)的过程时出现此错误。

我有table,stop_locations,两个相关的列是:

stop_distance DECIMAL(8,4) NOT NULL,
stop_bearing DECIMAL(16,13) NOT NULL,

这两个函数及其返回的值是:

CREATE FUNCTION distance ( lat1 DECIMAL(16,13), lon1 DECIMAL(16,13), lat2 DECIMAL(16,13), lon2 DECIMAL(16,13) )
RETURNS DECIMAL(8,4)
...

CREATE FUNCTION bearing180 ( lat1 DECIMAL(16,13), lon1 DECIMAL(16,13), lat2 DECIMAL(16,13), lon2 DECIMAL(16,13) )
RETURNS DECIMAL(16,13)

最后,产生我想要的结果的程序(即它有效),但也产生错误:

1265 Data truncated for column 'stop_distance' at X

stop_bearing列相同:

CREATE PROCEDURE UpdateLocations()
BEGIN
DECLARE lat1 DECIMAL(16,13);
DECLARE lon1 DECIMAL(16,13);

SELECT current_lat, current_lon INTO lat1, lon1 FROM current_location WHERE id = 1;

TRUNCATE TABLE stop_locations;

INSERT INTO stop_locations(stop_id, stop_distance, stop_bearing)
SELECT 
    stop_id, 
    DISTANCE(lat1, lon1, stop_lat, stop_lon) AS stop_distance,
    BEARING180(lat1, lon1, stop_lat, stop_lon) AS stop_bearing
FROM 
    stops;    
END

所以,如果函数距离 bearing180 返回 DECIMAL(8,4) DECIMAL(16,13) 分别和表列匹配,什么是截断,为什么消息?

感谢您的指导!

0 个答案:

没有答案