Home > Database > Mysql Tutorial > Detailed explanation of MySQL's method of creating a stored procedure and adding records in a loop

Detailed explanation of MySQL's method of creating a stored procedure and adding records in a loop

小云云
Release: 2018-01-17 10:31:47
Original
1800 people have browsed it

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template