错误代码:1324 Undefined CURSOR:OPEN

时间:2010-09-06 09:49:05

标签: mysql

嘿伙计们,我是mysql的新手。我写了一个错误发生的程序:

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 ;

错误讯息:

(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 Time  : 00:00:00:000
Total Time     : 00:00:00:000

1 个答案:

答案 0 :(得分:1)

你写了

OPEN OPEN curSoldCount;

尝试

OPEN curSoldCount;