You cannot use the same name for several different things. In particular, give the variable a different name than the column of your choice. For example, if you rename the variable v_link_rewrite, then it will probably work:
delimiter //
DROP PROCEDURE IF EXISTS some_func //
CREATE PROCEDURE some_func()
BEGIN
DECLARE v_link_rewrite VARCHAR(255);
DECLARE link_rewrite_cursor CURSOR FOR SELECT link_rewrite FROM prod;
OPEN link_rewrite_cursor;
SET @count = 0;
WHILE @count < 10 DO
FETCH link_rewrite_cursor INTO v_link_rewrite;
SELECT v_link_rewrite;
set @count = @count + 1;
END WHILE;
CLOSE link_rewrite_cursor;
END//
delimiter ;
source
share