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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 09:33:061047browse

mysql

<code> 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 $$</code>

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

<code> 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 ;</code>
<code> 错误代码: 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</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn