0

我尝试创建以下触发器:

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

4

1 回答 1

2

看看你的 phpmyadmin 版本中是否有 DILIMITER 字段,就在 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$$
于 2012-11-12T10:31:24.183 回答