MySQL - 使用多个参数创建存储过程

时间:2017-06-07 21:54:17

标签: mysql

我已经设置了如下表格:

mysql> describe schedules;
+---------+--------------+------+-----+---------+-------+
| Field   | Type         | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| Email   | varchar(255) | NO   | PRI | NULL    |       |
| Lunch   | int(11)      | YES  |     | NULL    |       |
| Classes | text         | YES  |     | NULL    |       |
| Labs    | text         | YES  |     | NULL    |       |
+---------+--------------+------+-----+---------+-------+

然后我尝试按如下方式为日程表创建存储过程:

DELIMITER $$
CREATE PROCEDURE updateSchedule(IN @email VARCHAR(255),
IN @lunch INT,
IN @schedule TEXT,
IN @labs TEXT)
BEGIN
REPLACE INTO schedules VALUES (@email, @lunch, @schedule, @labs);
END $$
DELIMITER ;

导致此错误:

ERROR 1064 (42000): 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 '@email varchar(255),
      IN @lunch INT,
      IN @schedule TEXT,
      IN @labs TEXT)
      BEGIN
      REPL' at line 2

我该如何解决这个问题?

0 个答案:

没有答案