Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Last active February 9, 2020 03:16
Show Gist options
  • Save uncoded-ro/a573be722afc9ff0d94033c1aa1b2103 to your computer and use it in GitHub Desktop.
Save uncoded-ro/a573be722afc9ff0d94033c1aa1b2103 to your computer and use it in GitHub Desktop.
DELIMITER |
DROP PROCEDURE IF EXISTS lefti.numerePare |
CREATE PROCEDURE lefti.numerePare(IN maxim INT)
BEGIN
DECLARE x INT;
DECLARE str VARCHAR(255);
SET x = 1;
SET str = '';
loop1: LOOP
IF x > maxim THEN LEAVE loop1;
END IF;
SET x = x + 1;
IF x mod 2 != 0 THEN ITERATE loop1;
ELSE SET str = CONCAT(str, x, ', ');
END IF;
END LOOP;
SELECT str;
END |
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment