mysql 语句错误
CREATE PROCEDURE dowhile()
BEGIN
DECLARE v1 INT DEFAULT 5;
WHILE v1 > 0 DO
SET v1 = v1 – 1;
END WHILE;
END
我运行mysql帮助里面的程序会报错,不知道为什么,请知道的告诉我一下
错误代码: 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 ‘INT DEFAULT 5’ at line 3
(耗费 0 ms)
错误代码: 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 ‘WHILE v1 > 0 DO
SET v1 = v1 – 1′ at line 1
(耗费 0 ms)
错误代码: 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 ‘END WHILE’ at line 1
(耗费 0 ms)
错误代码: 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 ‘END’ at line 1
(耗费 0 ms)
没试你的语句没有任何错误啊。
-
SQL code
mysql> delimiter // mysql> CREATE PROCEDURE dowhile() -> BEGIN -> DECLARE v1 INT DEFAULT 5; -> WHILE v1 > 0 DO -> SET v1 = v1 - 1; -> END WHILE; -> END -> // Query OK, 0 rows affected (0.44 sec) mysql> delimiter ; mysql> mysql> call dowhile; Query OK, 0 rows affected (0.00 sec) mysql>