SQLite 创建 AFTER UPDATE 触发器
Posted
技术标签:
【中文标题】SQLite 创建 AFTER UPDATE 触发器【英文标题】:SQLite creating an AFTER UPDATE Trigger 【发布时间】:2017-12-09 18:24:51 【问题描述】:我正在尝试创建一个 SQLite
触发器,它会在玩家每次达到 10
点时自动将字段 FlagPayment
设置为 1
,但是,显然我有语法错误。
CREATE TRIGGER aft_update AFTER UPDATE ON Player
FOR EACH ROW WHEN (NEW.ParticipationPoints % 10 = 0) and (NEW.ParticipationPoints > 0)
BEGIN
UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID
END;
这是结果:
“END”附近:语法错误:CREATE TRIGGER aft_update AFTER UPDATE ON 每一行的玩家(NEW.ParticipationPoints % 10 = 0)和 (NEW.ParticipationPoints > 0) BEGIN UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID END
【问题讨论】:
【参考方案1】:如documentation所示,触发器主体中的所有语句都必须以分号结束:
BEGIN
UPDATE Player SET FlagPayment = 1 WHERE ID = NEW.ID;
END; ^
【讨论】:
以上是关于SQLite 创建 AFTER UPDATE 触发器的主要内容,如果未能解决你的问题,请参考以下文章