I have this sql file:
USE mydb;
DROP PROCEDURE IF EXISTS execSql;
DELIMITER //
CREATE PROCEDURE execSql (
IN sqlq VARCHAR(5000)
) COMMENT 'Executes the statement'
BEGIN
PREPARE stmt FROM sqlq;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END //
DELIMITER ;
当我尝试使用以下命令运行:
# cat file.sql | mysql -p
我会得到以下错误:
ERROR 1064 (42000) at line 6: 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 'sqlq;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END' at line 5
我做错了什么?
FETCH [foo] INTO y
,在游标内部,您必须创建一个新的@yValue = y
并将其用于预处理语句。 - Russell Fox