According to the MySQL 8.0 deprecations notes, starting MySQL 9.0 the definition of user variables with DECLARE (e.g. DECLARE studentID INT) will be deprecated:
Support for setting user variables in statements other than
SETwas deprecated in MySQL 8.0.13. This functionality is subject to removal in MySQL 9.0.
Already nowadays MySQL 8.0.25 raises a warning:
1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives:
SET variable=expression, ..., orSELECT expression(s) INTO variables(s).
Therefore, I would like to understand how to properly replace DECLARE with SET. Let say, I have the following variables declared:
DECLARE cursor_studentID INT;
DECLARE done INT DEFAULT FALSE;
DECLARE cursor_i CURSOR FOR SELECT courseID FROM tblCoursesToCopy;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
And now I want to make these declaration MySQL 9.0 compatible. In case of DECLARE cursor_studentID INT; everything is relatively obvious:
DECLARE cursor_studentID INT; → SET @cursor_studentID;
The real obstacle is the last one case:
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
How to replace it with SET-based approach?
 
    