mysql - 导入存储过程时出现错误1064

标签 mysql stored-procedures import

我使用以下代码导入存储过程:

DELIMITER $$
--
-- Procedures
--
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `t_addToFlux`(IN `type` VARCHAR(255), IN `element_id` INT(11), IN `etudiant_id` INT(11))
BEGIN
    INSERT INTO stream(type, element_id, student_id) VALUES(type, element_id, etudiant_id);
END$$

但是当我在服务器上执行它时,我收到此错误:

1064 - 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 'PROCEDURE t_addToFlux(IN type VARCHAR(255), IN element_id INT(11), IN `etu' at line 6

我不知道为什么会出现这个错误

流表的结构:

enter image description here

创建者:

CREATE TABLE IF NOT EXISTS `stream` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(255) NOT NULL,
  `element_id` int(11) NOT NULL,
  `student_id` int(11) NOT NULL,
  `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `student_id` (`student_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

MySQL 版本:5.6.17 - MySQL 社区服务器 (GPL)

感谢您的帮助!

托马斯

最佳答案

我终于找到了我的问题的解决方案,我写在这里,如果它可以帮助一些人。

我的第一个请求是:

CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `t_addToFlux`(IN `type` VARCHAR(255), IN `element_id` INT(11), IN `etudiant_id` INT(11))
BEGIN
    INSERT INTO stream(type, element_id, student_id) VALUES(type, element_id, etudiant_id);
END$$

我尝试删除:

OR REPLACE

现在我的请求对我有用!

事实是“OR REPLACE”语句不适用于MySQL。

关于mysql - 导入存储过程时出现错误1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34544327/

相关文章:

mysql - 插入到选择中

Mysql一次插入插入多行

Mysql 未在 xampp 中启动 :Unexpected Shutdown

php - 在 Android Studio 中用 Double 解析 JSONArray

java - java中内连接的解析结果【性能相关】

Python 从上面的目录导入

c# - 在 ASP.NET 网页中枚举字典

SQL 服务器 : trying to create view inside a stored procedure

sql - 如何在 SQL Server 中反转字符串

sql - 如何快速将Microsoft SQL Server 2008中的表结构导出到Visio以制作ERD?