插入触发器之前的mysql

时间:2012-11-12 10:17:46

标签: mysql mysql-5.1

我尝试创建以下触发器:

DELIMITER $$

CREATE trigger insert_processor
BEFORE INSERT ON tbl
FOR EACH ROW BEGIN

set new.val = trim(new.val);
set new.val2 = upper(new.val);

END$$

并且失败并显示以下错误消息

#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 '' at line 8

可能是什么原因?

MySql服务器版本:5.1.40-community

客户:phpMyAdmin 3.3.8

1 个答案:

答案 0 :(得分:1)

看看你的phpmyadmin版本中是否有DELIMITER字段,就在SQL编辑器下面。在那里设置分隔符,例如 - '$$',并编写此SQL代码 -

CREATE trigger insert_processor
BEFORE INSERT ON tbl
FOR EACH ROW BEGIN

set new.val = trim(new.val);
set new.val2 = upper(new.val);

END$$