错误 1329:无数据 - 提取、选择或处理零行 - 即使一切都正确 [英] Error 1329: No data - zero rows fetched, selected, or processed - Even when all is done right

查看:53
本文介绍了错误 1329:无数据 - 提取、选择或处理零行 - 即使一切都正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面,我收到错误 1329:无数据 - 获取、选择或处理零行",即使所有操作都正确完成.我的其他功能可以正常工作,而这个功能在几天前​​还可以正常工作.

In the following, i get "Error 1329: No data - zero rows fetched, selected, or processed", even when all is done correctly. My other functions work, and this same one used to work well a few days ago.

BEGIN
    DECLARE Id INT(10) DEFAULT '0';
    DECLARE Elm INT(10) DEFAULT '0';
    DECLARE ElmParent INT(10) DEFAULT '0';
    DECLARE Type TINYINT(1) DEFAULT '0';
    DECLARE Processed TINYINT(1) DEFAULT '0';
    DECLARE Country VARCHAR(2) DEFAULT "";
    DECLARE updateDone INT DEFAULT 0;
    DECLARE Increment TINYINT(1) DEFAULT '0';

    -- declare cursor
    DEClARE updater CURSOR FOR
        SELECT id, klm, parent, type, processed, countryCode FROM votes where voteProcessed=0;

    -- declare NOT FOUND handler
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET updateDone = 1;

    OPEN updater;

    doUpdate: LOOP

        FETCH updater INTO Id, Elm, ElmParent, Type, Processed, Country;

        IF updateDone =1 THEN
            LEAVE doUpdate;
        END IF;

        IF Type = 0 THEN
            SET Increment = 1;
        ELSEIF Type = 1 THEN
            SET Increment = -1;
        END IF;

         -- update likes
        update likes set votes=votes+Increment where id=Elm and parent = ElmParent and country=Country;
        update votes set voteProcessed = 1 where id=Id;

    END LOOP doUpdate;

    CLOSE updater;

END

我在这里遗漏了什么吗?我使用的是 MySQL 5.5.25 版

Am I missing something here? I'm using MySQL version 5.5.25

推荐答案

我不确定是什么导致了这种情况,但将您的处理程序更改为更具体的 SQL 错误可能在这种情况下有效

I'm not sure what is causing this but changing your handler to the more specific SQL error might work in this case

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET updateDone = 1;

您可以尝试切换 if 和 fetch

You might try to swith the if and the fetch

    IF updateDone =1 THEN
        LEAVE doUpdate;
    END IF;

    FETCH updater INTO Id, Elm, ElmParent, Type, Processed, Country;

这可确保在 CONTINE HANDLER 已经表示您没有记录的情况下不会执行 FETCH.

this ensures that FETCH is not executed in the case the CONTINE HANDLER already signaled you're out of records.

至少在这里找到的解决方案

这篇关于错误 1329:无数据 - 提取、选择或处理零行 - 即使一切都正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆