我只是想使用觸發器而不是檢查約束和代碼之一,但它給了我一個錯誤。語法錯誤在mysql'觸發器'
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
TNX求助
您的* trigger_time *和* trigger_event *在哪裏? 'CREATE TRIGGER衝突 BEFORE UPDATE ON roozane' http://dev.mysql.com/doc/refman/5.5/en/create-trigger.html – DevlshOne
啊固定TNX但現在它轉發給INSERT命令和這裏顯示語法錯誤 – user2540401
對不起,但我不明白你最後的評論。你能否發佈你的更新後的查詢和錯誤? – DevlshOne