MySQL - Loop Function
DELIMITER //
CREATE FUNCTION GetLoop ( starting_value INT )
RETURNS INT
BEGIN
DECLARE result INT;
SET result = 0;
label1: LOOP
SET result = result + starting_value;
IF result < 1000 THEN
ITERATE label1;
END IF;
LEAVE label1;
END LOOP label1;
RETURN result;
END; //
DELIMITER ;