Stored Procedure Error
MySQL is particular about the order in which you do things in a CREATE PROCEDURE/FUNCTION statement. I'll be burned if I can find it in the docs right now, beyond a cursory mention under DECLARE Syntax, but the order MUST BE

Header
Declare variables
Declare cursors
Declare handlers
Do actual stuff


With your INSERT ... SELECT in place, you're attempting to declare variables after you've begun "doing stuff", which isn't allowed. Move the INSERT ... SELECT after the last of your DECLAREs, and things should work much better.