[英]Error on creating a stored procedure in MySQL, Error#1064
I'm having a hard time creating a stored procedure.我很难创建存储过程。 I have tried altering some things according to other entries on stack overflow but it did not help.我曾尝试根据堆栈溢出的其他条目更改一些内容,但没有帮助。
select version();
returns 5.7.31-0ubuntu0.16.04.1
incase that helps.返回5.7.31-0ubuntu0.16.04.1
万一。
DELIMITER $$
CREATE
PROCEDURE forceSubscribeToNode(IN node_id_var INT)
BEGIN
INSERT
INTO
xf_forum_watch(
user_id,
node_id,
notify_on,
send_alert,
send_email
)
SELECT
user_id,
node_id_var AS node_id,
"thread" AS notify_on,
1 AS send_alert,
1 AS send_email
FROM
xf_user
WHERE
user_group_id NOT IN(
1, 18, 40
)
ON DUPLICATE KEY
UPDATE
send_alert = 1,
send_email = 1,
notify_on = CASE WHEN notify_on IS NULL OR notify_on = '' THEN 'thread' ELSE notify_on END
END $$
DELIMITER ;
#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 'END' at line 30
(Line 18 is "send_email = 1," (第 18 行是“send_email = 1”,
This will be used for the forum software Xenforo 2.1 to force subscribe users to certain nodes like categories and sub-forums.这将用于论坛软件 Xenforo 2.1 强制订阅用户到某些节点,如类别和子论坛。
So it seems I forgot to add a ;
所以看来我忘了添加一个;
with a space before after the first END
在第一个END
之后有一个空格
DELIMITER $$
CREATE
PROCEDURE forceSubscribeToNode(IN node_id_var INT)
BEGIN
INSERT
INTO
xf_forum_watch(
user_id,
node_id,
notify_on,
send_alert,
send_email
)
SELECT
user_id,
node_id_var AS node_id,
"thread" AS notify_on,
1 AS send_alert,
1 AS send_email
FROM
xf_user
WHERE
user_group_id NOT IN(
1, 18, 40
)
ON DUPLICATE KEY
UPDATE
send_alert = 1,
send_email = 1,
notify_on = CASE WHEN notify_on IS NULL OR notify_on = '' THEN 'thread' ELSE notify_on END ;
END $$
DELIMITER ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.