MySQL存储过程语法错误

时间:2013-08-16 15:20:33

标签: mysql mysql-error-1064

我正在尝试通过MySQL监视器加载以下存储过程并收到此错误。相关表的模式如下。提前致谢:

  

错误1064(42000):您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在'附近使用。 p_lname VARCHAR,p_addr VARCHAR,p_cty VARCHAR,p_pcode INT,p_ctry VARCHAR,p _'在第1行

delimiter //
CREATE PROCEDURE saveProfile(
       p_fname VARCHAR,
       p_lname VARCHAR,
       p_addr  VARCHAR, 
       p_cty VARCHAR, 
       p_pcode INT,
       p_ctry VARCHAR, 
       p_ph INT,
       p_mail VARCHAR)                               
BEGIN
DECLARE v_usr INT;
UPDATE Users SET first_name = p_fname,
                  last_name = p_lname
             WHERE email = p_mail;
SET v_usr = (SELECT user_id from Users WHERE email = p_mail);
UPDATE Contact_info SET address = p_addr,
                        city = p_cty,
                        post_code = p_pcode,
                        country = p_ctry,
                        phone = p_ph 
                    WHERE user_id = v_usr;
END//
delimiter ;

mysql> describe Users;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| user_id    | int(11)      | NO   | PRI | NULL    | auto_increment |
| email      | varchar(255) | NO   | UNI | NULL    |                |
| password   | varchar(255) | YES  |     | NULL    |                |
| token      | varchar(255) | NO   |     | NULL    |                |
| verified   | tinyint(1)   | NO   |     | 0       |                |
| first_name | varchar(255) | YES  |     | NULL    |                |
| last_name  | varchar(255) | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+

mysql> describe Contact_info;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| address_id | int(11)      | NO   | PRI | NULL    | auto_increment |
| address    | varchar(255) | YES  |     | NULL    |                |
| city       | varchar(255) | YES  |     | NULL    |                |
| country    | varchar(255) | YES  |     | NULL    |                |
| post_code  | int(11)      | YES  |     | NULL    |                |
| phone      | varchar(30)  | YES  |     | NULL    |                |
| user_id    | int(11)      | YES  | MUL | NULL    |                |
| street     | varchar(255) | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+ 

0 个答案:

没有答案