gpt4 book ai didi

mysql - 如何在触发器 INSERT AFTER mysql 中执行过程?

转载 作者:行者123 更新时间:2023-11-30 22:55:44 25 4
gpt4 key购买 nike

我在这里发现了很多问题,例如: Execute procedure in a trigger

但不能在此处发表自己的评论以指定某些时刻。

我有触发器 INSERT AFTER,我在 phpmyadmin 中写道:

...

BEGIN
insert_log(1, :new.idArticle, :new.ArticleName, :new.ArticleTime, :new.ArticleCategory, :new.ArticleToUserID);
END
...

我得到错误:

MySQL: #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 '(1, :new.idArticle, :new.ArticleName, :new.ArticleTime, :new.ArticleCategory, :n' at line 2

你能告诉我哪里出了问题吗?

最佳答案

试试这个:

CREATE TRIGGER your_trigger
AFTER INSERT
ON table_name FOR EACH ROW
BEGIN
insert_log(1, NEW.idArticle, NEW.ArticleName, NEW.ArticleTime, NEW.ArticleCategory, NEW.ArticleToUserID);
END;

另请注意,MySQL 的文档页面标题为“Trigger Syntax and Examples”,其中指出:

 Within the trigger body, the OLD and NEW keywords enable you to access columns 
in the rows affected by a trigger. OLD and NEW are MySQL extensions to triggers;
they are not case sensitive.

如有任何问题,请告诉我!

关于mysql - 如何在触发器 INSERT AFTER mysql 中执行过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26474917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com