Stored procedure cursors, in fact, the result set, and then want to manipulate the result set of data, the cursor can be read line by line
First declare a cursor
delimiter $$
CREATE procedure changeName()
begin
declare stopflag int default 0;
declare myname varchar(20) default '';
declare my_cursor cursor for select sname from student where sid%2=0;
declare continue handler for not found set stopflag=1;
open my_cursor;
while(stopflag=0) do
begin
fetch my_cursor into myname;
update student set sname = concat(sname,'aab') where sname = myname;
end;
end while;
close my_cursor;
end;
$$
The above is the use of a cursor,
important point:
Cursor declaration need after all other variables, cursors often cooperate to achieve a state value, we need to declare a stop identity
declare continue handler for not found set identifier repose = 1;
Use the cursor first open, finally we need to close
Pick-fetch my_cursor into a cursor variable values