我想设置一个触发器,以便如果在更新时预测字段 = 3,则触发器将值更改为 4 并将其保存在数据库中。触发器如下。
出于某种原因,我不断收到错误消息:
#1442 - Can't update table 'tzanalytic\_forecast\_cached' in stored
function/trigger because it is already used by statement which invoked
this stored function/trigger.
这是正确的设置方式吗?
delimiter $$
CREATE TRIGGER no_BoW BEFORE UPDATE ON t FOR EACH ROW
BEGIN set @prediction = new.prediction;
UPDATE t SET t.prediction = (SELECT IF(@prediction = '3', '4', @prediction)) WHERE t.event_id = new.event_id AND t.price_tier = new.price_tier; END;
$$ delimiter ;