【发布时间】:2017-09-03 13:47:48
【问题描述】:
这是我写的触发器。
DELIMITER //
create trigger after_insert_bid
after insert on Bid
for each row
when exists(
select *
from Item
where ItemID = new.ItemID)
begin
update Item set Item.currently = NEW.amount where Item.itemID = NEW.itemID;
end;//
DELIMITER ;
它有一个错误:
ERROR 1064 (42000): 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 'when exists(
SELECT *
FROM Item
WHERE ItemID = new.ItemID
)
begin
UPDATE Item SE' at line 4
mysql> end;
我是mysql新手,我知道这是一个简单的问题,但我真的不知道如何找到错误,谢谢!
mysql版本是5.1.73
【问题讨论】:
-
您发现了错误。您是否检查了语法与手册中指定的内容?
-
我的版本是mysql 5.1.73。我试过在手册中找到它,但没有用。抱歉
-
你不能在那里做
WHEN EXISTS,所以你需要一种不同的方法。看看有哪些 trigger_event 类型。
标签: mysql error-handling triggers