gpt4 book ai didi

mysql - 错误代码: 1324 Undefined CURSOR: OPEN

转载 作者:行者123 更新时间:2023-11-29 14:59:27 25 4
gpt4 key购买 nike

嘿伙计们,我是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

最佳答案

你写的

OPEN OPEN curSoldCount;

尝试

OPEN curSoldCount;

关于mysql - 错误代码: 1324 Undefined CURSOR: OPEN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3650482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com