为什么这个SQL触发器不能保存任何数据?

时间:2016-06-30 12:57:48

标签: mysql sql triggers phpmyadmin

所以我有这个触发器:

delimiter $$
 CREATE TRIGGER check_liters 
 AFTER INSERT ON reports_data_sheet_area_brut
 FOR EACH ROW BEGIN
 IF (NEW.fuel > 10) THEN
    UPDATE fuel_check
    SET fuel_value = NEW.fuel
    Where id = NEW.vehicule_id;
 ELSEIF (NEW.fuel > 20) THEN
    UPDATE fuel_check
    SET fuel_value2 = NEW.fuel 
    Where id = NEW.vehicule_id;
 END IF;
END$$

可以在触发器上正确添加,但当燃料> 10或20时,它不会在fuel_check表中添加数据。

这是reports_data_sheet_area_brut:

http://i.prntscr.com/a1f7af8c28c447e98eb0cf111e544596.png

这是fuel_check表(触发器):

http://i.prntscr.com/75f1467563d14febbdfd8b749a11013d.png

当我尝试添加值时:

INSERT INTO reports_data_sheet_area_brut (vehicule_Id,area_Id,area,status_Id,status,start_time,end_time,duration,start_fuel_level_liters,end_fuel_level_liters,fuel,distance,consum_h )
                       VALUES
(43,432,"ceva",2,"Motor Oprit","2016-06-29 09:07:04","2016-06-30 10:07:06",30937,674,674,15,0,0);

在此SQL之后,它只会在reports_data_sheet_area_brut中添加列,但不会在触发器的fuel_check表中添加。

0 个答案:

没有答案