我只是想使用触发器而不是检查约束和代码一,但它给了我一个错误。
CREATE TRIGGER conflict
ON roozane
FOR EACH ROW
BEGIN
if rDate = NEW.rDate then
if NEW.rStartTime < rStartTime AND NEW.rEndTime < rEndTime then
INSERT INTO roozane (rID,rDate,rStartTime,rEndTime,rPlace,rComment,rType) values (NEW.rID,NEW.rDate,NEW.rStartTime,NEW.rEndTime,NEW.rPlace,NEW.rComment,NEW.rType);
end if
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 'ON roozane FOR EACH ROW BEGIN if ( rDate=NEW.rDate ) then if ( NEW.rStart' at line 2
编辑
CREATE TRIGGER conflict BEFORE INSERT
ON roozane
FOR EACH ROW
BEGIN
if rDate = NEW.rDate then
if NEW.rStartTime < rStartTime AND NEW.rEndTime < rEndTime then
INSERT INTO roozane (rID,rDate,rStartTime,rEndTime,rPlace,rComment,rType) values (NEW.rID,NEW.rDate,NEW.rStartTime,NEW.rEndTime,NEW.rPlace,NEW.rComment,NEW.rType);
end if
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 7
寻求帮助