Your DECKARE CURSOR Statment should be at the beginning of the procedure (or more precisely, at the beginning of a compound statement before any 'executable' SQL Statement ...
Ex:
BEGIN
DECLARE v_salary DOUBLE;
DECLARE v_years SMALLINT;
DECLARE v_id SMALLINT;
DECLARE at_end INT DEFAULT 0;
DECLARE not_found CONDITION FOR SQLSTATE '02000';
-- CAST salary as DOUBLE because SQL procedures do not support DECIMAL
DECLARE C1 CURSOR FOR
SELECT id, CAST(salary AS DOUBLE), years
FROM staff;
DECLARE CONTINUE HANDLER FOR not_found
SET at_end = 1;
SET v_id=100 ;
OPEN C1;
etc ...
If the declare currsor is after the SET v_id=100 statement, then you will get an error
HTH
Sathyaram