Advertisement
Rochet2

mysql stored procedure example

Sep 22nd, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.42 KB | None | 0 0
  1. -- based on
  2. -- https://dev.mysql.com/doc/refman/5.7/en/while.html
  3. -- https://dev.mysql.com/doc/refman/5.7/en/stored-programs-defining.html
  4. DROP PROCEDURE IF EXISTS `myproc`;
  5. DELIMITER $$
  6. CREATE PROCEDURE `myproc`()
  7. BEGIN
  8.     DECLARE i INT DEFAULT 1;
  9.     WHILE i <= 10 DO
  10.         INSERT INTO test (id) VALUES (i);
  11.         SET i = i + 1;
  12.     END WHILE;
  13. END $$
  14. DELIMITER ;
  15. CALL `myproc`;
  16. DROP PROCEDURE IF EXISTS `myproc`;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement