Home >Database >Mysql Tutorial >Detailed explanation of MySQL's method of creating a stored procedure and adding records in a loop
This article mainly introduces the method of creating stored procedures and adding records in a loop in MySQL, involving basic mysql stored procedure creation and calling related operation skills. Friends who need it can refer to it. I hope it can be a moderator for everyone.
Create first, then call:
-- 创建存储过程 DELIMITER;// create procedure myproc() begin declare num int; set num=1; while num <= 24 do insert into t_calendar_hour(hourlist) values(num); set num=num+1; end while; commit; end;// -- 调用存储过程 CALL myproc();
Related recommendations:
Explain in detail the stored procedure of mysql, Cursors, transactions
A brief introduction to MySQL stored procedures and transactions
MySQL stored procedures Sample code for cursor error handling
The above is the detailed content of Detailed explanation of MySQL's method of creating a stored procedure and adding records in a loop. For more information, please follow other related articles on the PHP Chinese website!