开始后MySQL存储过程语法错误 [英] MySQL stored procedure syntax error after BEGIN
问题描述
我正在尝试重新创建存储过程(因为我无法编辑主体).我调用了SHOW CREATE PROCEDURE,以使用与原始存储过程相同的格式,但是当我尝试重新创建它时,出现以下错误:
I am attempting to recreate a stored procedure (since I can't edit the body). I called SHOW CREATE PROCEDURE to use the same format as the original stored procedure but when I attempt to recreate it I get the following errors:
错误1064(42000):您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以获取在第11行的''附近使用的正确语法
ERROR 1064 (42000): 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 11
错误1064(42000):您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的'DECLARE organization_id BIGINT(20)UNSIGNED'附近使用
ERROR 1064 (42000): 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 'DECLARE organization_id BIGINT(20) UNSIGNED' at line 1
错误1064(42000):您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的"DECLARE lobby_pod_id BIGINT(20)UNSIGNED"附近使用
ERROR 1064 (42000): 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 'DECLARE lobby_pod_id BIGINT(20) UNSIGNED' at line 1
代码如下:
CREATE DEFINER=`lms`@`10.0.0.%` PROCEDURE `create_organization`(
IN admin_username VARCHAR(255),
IN organization_name VARCHAR(100)
)
BEGIN
DECLARE admin_user_id BIGINT(20) UNSIGNED;
DECLARE organization_id BIGINT(20) UNSIGNED;
DECLARE lobby_pod_id BIGINT(20) UNSIGNED;
SELECT ID, account INTO admin_user_id, organization_id
FROM users
WHERE username = admin_username;
INSERT INTO pods (`title`, `description`, `owner`, `scene`)
VALUES (CONCAT(organization_name, " Village"),
CONCAT("General meeting space and hub for ", organization_name, " students and teachers."),
admin_user_id,
" Village"
);
END
我粘贴到 SQL Fiddle 并得到了相同的结果,尽管粘贴到
I pasted into SQL Fiddle and got the same result, although pasting into MySQL Syntax Check gave me the thumbs-up. I'm sure it's a simple miss but it isn't that obvious to me.