2017-10-18 98 views
0

MySQL的触发语法错误?

delimiter || 
 
create trigger bins_chk 
 
before insert on VEHICLE 
 
on each row 
 
begin 
 
\t if (new.`Vehicle_type`= 'car') then 
 
\t \t if (new.`Tonnage` != null or new.`No_Seats` <> null) then 
 
\t \t \t signal sqlstate "45000" 
 
\t \t \t \t set message_text "Do not match!"; 
 
\t elseif new.`Vehicle_type`= 'suv' then 
 
\t \t if new.`Tonnage`<>null or new.`Engine_size`<>null then 
 
\t \t \t signal sqlstate "45000" 
 
\t \t \t \t set message_text "Do not match!"; 
 
\t elseif new.`Vehicle_type`= 'truck' then 
 
\t \t if new.`Engine_size`<>null or new.`No_Seats`<>null then 
 
\t \t \t signal sqlstate "45000" 
 
\t \t \t \t set message_text "Do not match!"; 
 
\t end if; 
 
end || 
 
delimiter;

哪里出了问题,我只是不知道如何解决它。

错误1064(42000):您的SQL语法错误;检查对应于你的MySQL服务器版本的权利 语法上的每一行使用近”的 手动开始是否有新的。 Vehicle_type = 'car' 那么如果新。 Tonnage <> null“在3线

+0

对于每一行不是在每行 –

+0

BUG! '<> null'不会做你的想法。更改为'IS NOT NULL'。 –

回答