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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:33:06
Original
1048 people have browsed it

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>
Copy after login

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

<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>
Copy after login
<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>
Copy after login
Related labels:
Statement of this Website
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template