gpt4 book ai didi

插入触发器之前的mysql

转载 作者:行者123 更新时间:2023-11-29 14:12:00 25 4
gpt4 key购买 nike

我尝试创建以下触发器:

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

最佳答案

看看您的 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$$

关于插入触发器之前的mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341869/

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