TRIGGER上的未知列错误

时间:2018-05-29 12:14:40

标签: mysql triggers onupdate

我在MySQL数据库中创建了一个触发器,用于将名为“gps_coordinates”的列设置为等于名为“previous_gps_coordinates”的列,然后再使用新值进行更新。

问题在于测试,我收到以下错误消息:

Error Code: 1054. Unknown column 'gps_coordinates' in 'field list'

我的表格结构如下:

|Location Number| gps_coordinates | previous_gps_coordinates
|105285         |Value can be NULL| Value can be NULL
|125896         |Value can be 0   | Value can be 0

我的触发器如下:

DELIMITER $$

CREATE TRIGGER GPSUPDATE
BEFORE UPDATE 
ON sys_reference.location_reference
FOR EACH ROW 

BEGIN   
IF NEW.previous_gps_coordinates >= 0 THEN   
SET NEW.previous_gps_coordinates := gps_coordinates;    
END IF;
END$$
DELIMITER ;

我也试过了以下的变体:

DELIMITER $$

CREATE TRIGGER GPSUPDATE
BEFORE UPDATE 
ON sys_reference.location_reference
FOR EACH ROW 

BEGIN   
IF NEW.previous_gps_coordinates IS NULL THEN    
SET NEW.previous_gps_coordinates := gps_coordinates;    
END IF;
END$$
DELIMITER ;

任何帮助都将在这里受到赞赏。 感谢

0 个答案:

没有答案