You have not declared a handler -
drop procedure if exists p;
delimiter $$
CREATE PROCEDURE p()
BEGIN
DECLARE i VARCHAR(100);
DECLARE a VARCHAR(100);
declare finished int default 1;
DECLARE cur1 CURSOR FOR
SELECT TABLE_NAME, COLUMN_NAME
FROM information_schema.columns
WHERE (COLUMN_NAME LIKE 'End%' OR COLUMN_NAME LIKE 'Expired%')
AND TABLE_SCHEMA='sandbox'
AND TABLE_NAME NOT LIKE 'discount%' ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET FINISHED = 0;
OPEN cur1;
read_loop: LOOP
IF FINISHED = 0 THEN
LEAVE read_loop;
END IF;
FETCH cur1 INTO i,a;
#SELECT i,a; -- printing table name
SET @s = CONCAT('select * from ', i, ' where ', a, ' >= CURDATE() + INTERVAL 90 DAY AND ' , a, ' <
CURDATE() + INTERVAL 91 DAY');
PREPARE stmt1 FROM @s;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
#select @s;
END LOOP read_loop;
CLOSE cur1;
END $$
delimiter ;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…