delimiter // create procedure p2() begin declare row_id int DEFAULT 0; declare row_num int DEFAULT 0; declare done int default False; declare temp int DEFAULT 0; declare my_cursor cursor for select id, num from a; declare continue handler for not fou…