【发布时间】:2011-04-03 21:29:45
【问题描述】:
我在 phpMyAdmin 工作,我是创建 MySQL 5.0.45 触发器的新手。我正在尝试创建一个触发器,该触发器将通过在值超出范围时引发错误来帮助我验证数据。
这很好用:
create trigger t1
before insert
on hvi
for each row
begin
declare dummy int;
if new.`Moist (dry%)` <1 then
select `Moist(dry%) cannot be less than 1`
into dummy
from hvi
where id = new.`Moist (dry%)`;
end if;
end;
但我需要为此触发器添加更多操作。我厌倦了这个:
create trigger t1
before insert
on hvi
for each row
begin
declare dummy int;
if new.`Moist (dry%)` <1 then
select `Moist(dry%) cannot be less than 1`
into dummy
from hvi
where id = new.`Moist (dry%)`;
end if;
if new.`Moist (dry%)` >50 then
select `Moist(dry%) cannot be greater than 50`
into dummy
from hvi
where id = new.`Moist (dry%)`;
end if;
end;
但是它返回了这个错误“#1235 - 这个版本的 MySQL 还不支持'多个触发器具有相同的动作时间和事件的一个表'”
有谁知道如何向触发器添加多个操作? (多个 if-then 语句?我最终需要添加大约 20 个。)
谢谢!
【问题讨论】:
标签: mysql sql triggers mysql-error-1235