Error Code : 1324 Undefined CURSOR: OPEN
hey guys,i'm new to mysql.here i wrote a procedure that error occured:
DELIMITER $$
USE `flower2`$$
DROP PROCEDURE IF EXISTS `test`$$
CREATE PROCEDURE `test`()
BEGIN
DECLARE soldcount INT;
DECLARE goodsid INT;
DECLARE not_found INT;
DECLARE curGoodsId CURSOR FOR SELECT goods_id FROM ecs_order_goods;
DECLARE curSoldCount CURSOR FOR SELECT sold_count FROM ecs_goods;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET not_found = 1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
START TRANSACTION;
OPEN curGoodsId;
OPEN OPEN curSoldCount;
WHILE not_found = 0 DO
FETCH curSoldCount INTO soldcount;
FETCH curGoodsId INTO goodsid;
SELECT COUNT(goods_id) FROM ecs_order_goods INTO soldcount;
UPDATE ecs_goods SET sold_count=soldcount WHERE goods_id=goodsid;
IF NOT not_found THEN
SET not_found = 0 ;
END IF;
END WHILE;
CLOSE curGoodsId;
CLOSE curSoldCount;
COMMIT;
END$$
DELIMITER ;
Error message:
(0 row(s) affected)
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:015
Total Time : 00:00:00:015
(0 row(s) affected)
Execution Time : 00:00:00:000
Transfer Time : 00:00:01:141
Total Time : 00:00:01:141
Query : **CREATE PROCEDURE `test`() BEGIN DECLARE soldcount INT; DECLARE goodsid int; DECLARE not_found INT; DECLARE curGoodsId CURSOR ...
Error Code : 1324
Undefined CURSOR: OPEN**
Execution Time : 00:00:00:000
Transfer T开发者_如何学编程ime : 00:00:00:000
Total Time : 00:00:00:000
You wrote
OPEN OPEN curSoldCount;
Try
OPEN curSoldCount;
精彩评论