错误插入
delimiter $$ //以delimiter来标记用$表示存储过程结束
create procedure pre() //创建pre()存储方法
begin
declare i int; //定义i变量
set i=6001;
while i<6021 do //对i的值配置
insert into assisted_material (id,name,edition_id,stages_id,grade_id,subject_id,volume,type,status,price,chapter_id,publisher)
values(i,"老师课本+",111,2,2,1,"3","material","enabled","50",3,"人民出版社");
set i=i+1; //自增循环
end while;
end
$$ //存储过程结束
call pre(); //调用pre()存储方法
正确插入
delimiter $$
create procedure pr()
begin
declare i int;
set i=5000;
while i<6000 do
insert into assisted_material (id,name,edition_id,stages_id,grade_id,subject_id,volume,type,status,price,chapter_id,publisher)
values(i,"老师课本+",111,2,2,1,"3","material","enabled","50",3,"人民出版社");
set i=i+1;
end while;
end
$$
call insertdata();
错误原因:
(1)第一次是因为call insertdata();这行语句没有添加或者添加后没有和其他代码块一起执行,一直检查其他地方;
(2)第二次是因为call insertdata();和头部create procedure pre()中的名称不一致;
总结:
认真做事