为什么这个触发器没有执行?

时间:2016-09-26 07:57:28

标签: mysql sql database

我在allowed_student {% assign preprocessed_content=post.content | replace: '<p>', '__p__' %} {% assign preprocessed_content=preprocessed_content | replace: '</p>', '__/p__' %} {% assign truncated_content=preprocessed_content | strip_html | truncatewords:50 %} {% assign cleaned_content=truncated_content | replace: '__p__', '<p>' %} {% assign cleaned_content=cleaned_content | replace: '__/p__', '</p>' %} <p>{{ cleaned_content }}</p> 触发器代码中插入后使用trigger来触发:

using mysql.
This is my

这是我使用触发器的表格:

enter image description here

这是我的触发器的表格:

enter image description here

当我执行触发器代码时,它会给我以下错误:

enter image description here

1 个答案:

答案 0 :(得分:1)

对于非PHPMyAdmin,请尝试:

DROP TRIGGER IF EXISTS Record_after_insert;
DELIMITER //
CREATE TRIGGER Record_after_insert
AFTER INSERT
   ON admitted_student FOR EACH ROW

BEGIN
   INSERT INTO student_audit (action,id,attime,who)
   SELECT 'something',NEW.admitted_student_id,now(),CURRENT_USER();
END; //
DELIMITER ;

for PHPMyAdmin尝试:

DROP TRIGGER IF EXISTS Record_after_insert;
CREATE TRIGGER Record_after_insert
AFTER INSERT
   ON admitted_student FOR EACH ROW

BEGIN
   INSERT INTO student_audit (action,id,attime,who)
   SELECT 'something',NEW.admitted_student_id,now(),CURRENT_USER();
END;

PHPMyAdmin不会使用DELIMITERCURRENT_USER()是您在登录时解决的用户。

who VARCHAR(10)应该像VARCHAR(100)

attime应该是DATETIME而不是它。