Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 1329: No data - zero rows fetched, selected, or processed - Even when all is done right

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

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

like image 943
Norman Avatar asked Dec 05 '25 10:12

Norman


1 Answers

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;

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;

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

solution at least found in here

like image 67
rene Avatar answered Dec 07 '25 04:12

rene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!