我有一個代碼觸發器之前插入MySQLfor過濾器數據,但它不起作用。這是邏輯的我的代碼,如果new.suhu_udara> 30 new.suhu_udara - old.suhu_udara < 10然後設置new.suhu_udara = NULL如何使用觸發器的mysql過濾器
USE `cuaca_maritim`;
DELIMITER $$
DROP TRIGGER IF EXISTS cuaca_maritim.filter$$
USE `cuaca_maritim`$$
CREATE DEFINER=`root`@`localhost` TRIGGER `filter` BEFORE INSERT ON data_cuaca` FOR EACH ROW
if(new.suhu_udara < 21.5 or new.kelembaban_udara < 22 or new.tekanan_udara < 1002.4) then
Set new.suhu_udara = null ;
elseif (new.suhu_udara > 37.6 or new.kelembaban_udara > 100 or new.tekanan_udara >1018.9 or new.kecepatan_angin > 44) then
Set new.kelembaban_udara = null ;
end if$$
DELIMITER ;
USE `cuaca_maritim`;
DELIMITER $$
DROP TRIGGER IF EXISTS cuaca_maritim.data_cuaca_AFTER_UPDATE$$
USE `cuaca_maritim`$$
CREATE DEFINER = CURRENT_USER TRIGGER `cuaca_maritim`.`data_cuaca_AFTER_UPDATE` AFTER UPDATE ON `data_cuaca` FOR EACH ROW
if (old.suhu_udara - new.suhu_udara > 10) then
set new.suhu_udara=null ;
end if
$$
DELIMITER ;
你能幫MEX這個代碼?
最新錯誤? –