- 查询存储过程
show procedure status where db='数据库名';
- 删除存储过程(test为存储过程名称)
drop procedure if exists test;
- 创建存储过程和调用(里面涉及到循坏和游标)
delimiter
drop procedure if exists test;
create procedure test()
begin
declare score int;
declare temp_id int;
declare flag int default 0;
declare s_list cursor for select id, login_score + course_study_score + live_study_score + book_study_score + interactive_score + homework_score +station_score from stu_grade_record;
declare continue handler for not found set flag=1;
open s_list;
fetch s_list into temp_id, score;
while flag <> 1 do
update stu_grade_record set usually_score=score where id=temp_id;
fetch s_list into temp_id, score;
end while;
close s_list;
end
delimiter ;
call test();