欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql-MySQL:为什么这样的小改动会造成存储过程错误呢?

程序员文章站 2022-05-13 11:45:01
...
mysql
 DELIMITER $$                  USE mysql$$DROP PROCEDURE IF EXISTS demo$$CREATE PROCEDURE demo(_id INT, _content VARCHAR(64))    BEGIN                  SET @id = _id;    SET @content = _content;                                                                                          PREPARE stmt FROM "INSERT INTO blog (id, content) VALUES(?, ?)";    EXECUTE stmt USING @id, @content;    DEALLOCATE PREPARE stmt;END$$DELIMITER ;DELIMITER $$

如果改写成如下就会报错:

 DELIMITER $$USE mysql$$DROP PROCEDURE IF EXISTS demo$$CREATE PROCEDURE demo(_id INT, _content VARCHAR(64))    BEGIN                  -- set @id = _id;    -- set @content = _content;    PREPARE stmt FROM "INSERT INTO blog (id, content) VALUES(?, ?)";    EXECUTE stmt USING _id, _content;    DEALLOCATE PREPARE stmt;END$$DELIMITER ;
 错误代码: 1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_id, _content;    DEALLOCATE PREPARE stmt;END' at line 7
相关标签: mysql