Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 我的触发器无法启动,我不明白为什么_Mysql_Sql - Fatal编程技术网

Mysql 我的触发器无法启动,我不明白为什么

Mysql 我的触发器无法启动,我不明白为什么,mysql,sql,Mysql,Sql,我试图创建此触发器,但出现以下错误: 您的SQL语法有错误;查看与MySQL服务器版本对应的手册,以了解第7行“case where artcStackId=new.artcStackId”附近使用的正确语法 这是失败的触发器 SET new.artcPublicId = case when new.artcCountry = 'US' then concat(91,new.artcStackId) when new.artcCountry = 'UK' then concat(92,

我试图创建此触发器,但出现以下错误:

您的SQL语法有错误;查看与MySQL服务器版本对应的手册,以了解第7行“case where artcStackId=new.artcStackId”附近使用的正确语法

这是失败的触发器

SET new.artcPublicId = 
 case 
 when new.artcCountry = 'US' then concat(91,new.artcStackId)
 when new.artcCountry = 'UK' then concat(92,new.artcStackId)
 when new.artcCountry = 'CA' then concat(93,new.artcStackId)
 else concat(11,new.artcStackId)
 end case
 where artcStackId = new.artcStackId
这是有效的触发器

SET new.artcPublicId = 
case 
when new.artcCountry = 'US' then concat(91,new.artcStackId)
when new.artcCountry = 'UK' then concat(92,new.artcStackId)
when new.artcCountry = 'CA' then concat(93,new.artcStackId)
else concat(11,new.artcStackId)
end

当我添加这些额外的位时,它将失败。

您的第一个触发器有语法错误:

end case
应该是公正的

end
ie移除尾随的“案例”

编辑: 我刚刚注意到您有一个where条件:
where-artcStackId=new.artcStackId

你不能那样做。您只能修改当前行,该行由
new.
语法引用


您必须完全删除where子句,因为您只能更新正在插入/更新的行。

没有对where条件的引用。我认为应该像
where new.artcStackId=new.artcStackId

您确定第一个子句中的“结束情况”吗?您打算让
where
子句做什么?
=
左侧的
artcStackId
是从哪里来的?在Where条件下,artcStackId是什么?显示完整代码。即使在我删除案例后,也会出现相同的错误。除了现在它从“where”开始。这是一种非常复杂的方法来确保
artcStackId
不为空吗?否则,如果它有一个值,我就看不到
WHERE
子句给查询带来了什么。