Mysql 触发器上的错误 1064
Error 1064 on Mysql trigger
我正在 MySQL 中编写一个触发器来记录 table 更新。日志table被称为individuo_storico,目标table被称为individuo。更新 individuo 时,我想检查 IDQualifica 和 IDLivello 是否已更改,如果是,则插入 individuo_storico 中的记录。
我写下这段代码,但出现#1064 错误,语法错误在哪里?
use ore;
create trigger individuo_update after update on individuo
for each row
begin
if ( NEW.IDLivello <> OLD.IDLivello or NEW.IDQualifica <> OLD.IDQualifica) then
insert into individuo_storico(IDIndividuo, IDQualifica, IDLivello)
values (NEW.IDIndividuo, NEW.IDQualifica, NEW.IDLivello);
end if;
end;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
请使用必要的名字对象包装您的触发器创建,这样数据库引擎就不会阻塞它。所以三个区域:
1) line 1
2) right after the end;
3) and then a reset to a default delimiter.
存储过程创建的典型概念相同。
DELIMITER $$
create trigger individuo_update after update on individuo
for each row
begin
if ( NEW.IDLivello <> OLD.IDLivello or NEW.IDQualifica <> OLD.IDQualifica) then
insert into individuo_storico(IDIndividuo, IDQualifica, IDLivello)
values (NEW.IDIndividuo, NEW.IDQualifica, NEW.IDLivello);
end if;
end;$$
DELIMITER ;
我正在 MySQL 中编写一个触发器来记录 table 更新。日志table被称为individuo_storico,目标table被称为individuo。更新 individuo 时,我想检查 IDQualifica 和 IDLivello 是否已更改,如果是,则插入 individuo_storico 中的记录。
我写下这段代码,但出现#1064 错误,语法错误在哪里?
use ore;
create trigger individuo_update after update on individuo
for each row
begin
if ( NEW.IDLivello <> OLD.IDLivello or NEW.IDQualifica <> OLD.IDQualifica) then
insert into individuo_storico(IDIndividuo, IDQualifica, IDLivello)
values (NEW.IDIndividuo, NEW.IDQualifica, NEW.IDLivello);
end if;
end;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
请使用必要的名字对象包装您的触发器创建,这样数据库引擎就不会阻塞它。所以三个区域:
1) line 1
2) right after the end;
3) and then a reset to a default delimiter.
存储过程创建的典型概念相同。
DELIMITER $$
create trigger individuo_update after update on individuo
for each row
begin
if ( NEW.IDLivello <> OLD.IDLivello or NEW.IDQualifica <> OLD.IDQualifica) then
insert into individuo_storico(IDIndividuo, IDQualifica, IDLivello)
values (NEW.IDIndividuo, NEW.IDQualifica, NEW.IDLivello);
end if;
end;$$
DELIMITER ;