The following code was used for finding the first five highest paid employee from a table named employee7 and add the details to another table named temp using cursor in mysql but I got the error
you have an error in your mysql syntax check the mannual that corresponds to mysql server version for the right syntax to use near 'loop cursorloop; close c7; end; at line 17
DELIMITER //
create procedure cursordemo()
begin
declare eno int(8);
declare ename varchar(15);
declare esal int(10);
declare c7 cursor for select empno,empnm,empsal from employee7 order by empsal desc;
open c7;
cursorloop:loop
fetch c7 into eno,ename,esal;
if c7.rowcount>5 then
leave cursorloop;
insert into temp values (esal,eno,ename);
end loop cursorloop;
close c7;
end //
delimiter ;
insert into temp values ([columns]) select [columns] from employee7 order by empsal desc