Error message:
ERROR 1337 (42000): Variable or condition declaration after cursor or handle
wrong reason:
All declared variables should be placed after the cursor
solve:
DECLARE name VARCHAR(64); -- traverse the end of data flag DECLARE done INT DEFAULT FALSE; DECLARE tables_cur CURSOR FOR select 。。。; -- bind the end marker to the cursor DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
There are two concepts in it:
cursor 和 handler