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)
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)
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>
mysql> delimiter ;
mysql>
mysql> call dowhile;
没有反应
Query OK, 0 rows affected (0.00 sec)mysql> select version();
+----------------------+
| version() |
+----------------------+
| 5.1.33-community-log |
+----------------------+
1 row in set (0.00 sec)mysql>
估计是你的客户端对版本检查的语法问题
你试下用mysql客户端直接运行看看
delimiter //
CREATE PROCEDURE insertvalue(id int)
BEGIN
DECLARE v1 INT DEFAULT 0;
WHILE v1 < 64 DO
insert into world_value_data (worldid,value_idx) values (id,v1);
SET v1 = v1 + 1;
END WHILE;
END
//call insertvalue() //
上面的代码可以