存储过程 插入主表
drop procedure sert5; delimiter // create procedure sert5() begin declare i_str char(10); declare j_str char(10); declare k_str char(10); declare m_str char(10); declare i int; declare j int; declare k int; declare m int; set i=1; set j=1; set k=1; set m=1; delete from class; delete from detailss; while i <= 99 do set i_str = right(concat('00',i),2); set i=i+1; insert into class(id,current_code,total_code) values(i_str,1,4); set j = 1; while j <= 5 do set j_str = right(concat('00',j),2); set j_str = concat(i_str,j_str); insert into class(id,current_code,total_code) values(j_str,2,4); set j=j+1; set k=1; while k <= 5 do set k_str =concat('000000',k); set k_str =right(k_str,6); set k=k+1; set k_str =concat(j_str,k_str); insert into class(id,current_code,total_code) values(k_str,3,4); end while; end while; end while; end// delimiter ;