MySQL compound statement problem
Posted on 2009-04-06
I am a first time user for MySQL compound statements.
I figured out that this shoud be the one I need
DECLARE iDone INT DEFAULT 0;
DECLARE sUsr VARCHAR(50);
DECLARE iMax INT(10);
DECLARE c_Upd CURSOR FOR SELECT szUser, MAX(TotalPages) FROM test GROUP BY szUser;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iDone = 1;
FETCH c_Upd INTO sUSR, iMax;
IF NOT done THEN
UPDATE Test SET MaxPages = iMax WHERE szUser = sUSR;
UNTIL iDone END REPEAT;
but whatever I try to change on de DECLARE line I always get
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'DECLA
RE iDone INT DEFAULT 0;
at line 2
I have tried several things even the simplest one
DECLARE iDone INT;
will not work.
I am using Server version: 5.1.30-community MySQL Community Server (GPL).
What do I do wrong?