Ask a stored procedure problems

When writing a stored procedure has encountered a problem:
Countinue handler for not found SQL anomaly can not only capture abnormal vernier boundary, can capture the abnormal select id into XXX similar statements?
Results the stored procedure I also used a lot of select XX into XXX statement, each time the cursor still perform the first row is over.
Don't know how to solve such problems in MySQL?

A demo code
BEGIN
	DECLARE notdone INT DEFAULT 1;
	DECLARE aid,abackup,b VARCHAR(255);
	DECLARE count int DEFAULT 0;
	DECLARE cur CURSOR FOR
	SELECT id,`backup`
	from advspace where `backup`=1;
	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET notdone = 0;

	open cur;
	fetch cur into aid,abackup;
	WHILE notdone DO
		set count = count +1;
		IF abackup=1 THEN
			SELECT id into b from advspace where `backup` = 2;
			update advspace set pathNumber = 2;
		END if;
	fetch cur into aid,abackup;
	select aid;
	END WHILE;
	CLOSE cur;
END

Started by Frederic at November 27, 2016 - 1:30 PM

PS: I checked exception code
The message the number FETCH of variables: incorrect.

· Error: 1329 SQLSTATE: 02000 (ER_SP_FETCH_NO_DATA)
FETCH news: no data.

· Error: 1330 SQLSTATE: 42000 (ER_SP_DUP_PARAM)
Who knows what this two?

Posted by Frederic at November 29, 2016 - 1:33 PM

Posted by Darren at December 11, 2016 - 2:15 PM

BEGIN
DECLARE notdone INT DEFAULT 1;
DECLARE aid,abackup,b VARCHAR(255);
DECLARE count int DEFAULT 0;
DECLARE cur CURSOR FOR
SELECT id,`backup`
from advspace where `backup`=1;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET notdone = 0;

open cur;
fetch cur into aid,abackup;
WHILE notdone DO
set count = count +1;
IF abackup=1 THEN
SELECT id into b from advspace where `backup` = 2;
update advspace set pathNumber = 2;
END if;
fetch cur into aid,abackup;
select aid;
END WHILE;
CLOSE cur;
END

Posted by Darren at December 24, 2016 - 3:04 PM

Not good, in the SELECT ID into B from advspace where `backup` = 2; when he jumped out of the

Posted by Frederic at January 01, 2017 - 3:53 PM