DROP PROCEDURE IF EXISTS test.t1 $$
DELIMITER $$
CREATE PROCEDURE t1()
BEGIN
SET autocommit=0;
DECLARE cnt INT DEFAULT 0; -- it is wrong order
WHILE cnt <= 10000 DO
INSERT INTO t1 VALUES (cnt);
SET cnt = cnt +1;
END WHILE;
COMMIT;
END$$
DELIMITER ;
and when run the sql block; there was error info , follow this:
Error Code: 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 'DECLARE cnt INT DEFAULT 0;
WHILE cnt <= 10000 DO
INSERT INTO' at line 4
[solved way]: declare must be set before autocommit;
DELIMITER $$
DROP PROCEDURE IF EXISTS test.t1 $$
DELIMITER $$
CREATE PROCEDURE t1()
BEGIN
DECLARE cnt INT DEFAULT 0; -- it is right order
SET autocommit=0;
WHILE cnt <= 10000 DO
INSERT INTO t1 VALUES (cnt);
SET cnt = cnt +1;
END WHILE;
COMMIT;
END$$
DELIMITER ;
Execution Time : 0.005 sec
Transfer Time : 0.097 sec
Total Time : 0.102 sec
阅读(1715) | 评论(0) | 转发(0) |