Skip to content

Instantly share code, notes, and snippets.

@FelipeGangrel
Created December 18, 2017 16:48
Show Gist options
  • Save FelipeGangrel/825b16cb656d7d73a9baf93da84fc00e to your computer and use it in GitHub Desktop.
Save FelipeGangrel/825b16cb656d7d73a9baf93da84fc00e to your computer and use it in GitHub Desktop.
mysql procedure com loop
drop procedure if exists testeLoop;
DELIMITER //
CREATE PROCEDURE testeLoop(INOUT numero INT(11))
BEGIN
DECLARE i INT DEFAULT 1;
TRUNCATE TABLE teste;
WHILE (i <= numero) DO
INSERT INTO teste (nome) values (CONCAT('teste - ', i));
SET i = i+1;
END WHILE;
END;
//
set @numero = 25000;
call testeLoop(@numero);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment