首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql 语句异常

2012-02-02 
mysql 语句错误CREATE PROCEDURE dowhile()BEGINDECLARE v1 INT DEFAULT 5WHILE v1 0 DOSET v1 v1 -

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> 

热点排行