drop procedure s1; delimiter // create procedure s1() begin declare i_str char(10); declare j_str char(10); declare k_str char(10); declare m_str char(50); 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); set m=1; while m<=1000 do set m_str=concat('0000',m); set m_str=right(m_str,4); set m_str=concat(k_str,m_str); insert into detailss(id) values(m_str); set m=m+1; end while; end while; end while; end while; end// delimiter ;