存储过程中使用循环处理数据,
create
definer = root@localhost procedure prls()
begin
declare done boolean default 0;
declare _name varchar(20);
declare _time datetime;
declare _password varchar(20);
declare ordernum cursor for
select user_name, create_time, user_password from user_copy;
-- 根据sqlstate设置继续与否
declare continue handler for sqlstate '02000' set done = 1;
open ordernum;
repeat
fetch ordernum into _name,_time,_password;
insert into user(user_name, create_time, user_password) value (_name,_time,_password);
until done end repeat;
close ordernum;
end;
标签:存储,name,time,ordernum,循环,user,MySQL,password,declare
From: https://www.cnblogs.com/JarryShu/p/17008617.html