开发者

MySQL - AFTER INSERT TRIGGER does not run UPDATE query?

开发者 https://www.devze.com 2022-12-31 22:41 出处:网络
Using MySQL 5.1.x Trying to add a trigger to a table: DELIMITER $$ CREATE TRIGGER 开发者_JAVA百科group AFTER INSERT ON dataTable

Using MySQL 5.1.x

Trying to add a trigger to a table:

DELIMITER $$

CREATE TRIGGER 开发者_JAVA百科group AFTER INSERT ON dataTable
FOR EACH ROW BEGIN
UPDATE dataTable SET groupName = mid(longName,1,4) WHERE groupNAME IS NULL;
END$$

When I insert a record there is no update made. Is there a syntax error? Or can I not run the Update query on the after insert event?

UPDATE: There are 2 triggers on this table (a AFTER INSERT and BEFORE UPDATE).


In a MySQL trigger, you cannot invoke DML on the table that fires the trigger.

0

精彩评论

暂无评论...
验证码 换一张
取 消