I created this test procedure :
DELIMITER //
CREATE PROCEDURE `str` (IN var1 INT)
BEGIN
WHILE var1 < 5 DO
SELECT var1;
SET var1 = var1 + 1;
END WHILE;
END //
DELIMITER ;
when I run it via phpmyadmin, nothing happens. no error, no confirm message. If I CALL str(1), I get a message saying the procedure doesn’t exist. What’s wrong here?
If you want to get the iterated value of
var1you need theSELECToutside of theWHILEloop. The following works fine in my MySQL install:Executing
CALL str(1)returns5