i\'m trying to create a cursor for the first time. I have looked at the documentation, i understand the concept, but i can\'t seem to get it to even be declared...
I
create or replace procedure cursor_sample()
BEGIN
DECLARE done int default 0 ;
DECLARE data1 varchar(20) ;
DECLARE data2 int ;
DECLARE cur1 CURSOR FOR
select sname,examscore from student ;
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET done = 1 ;
OPEN cur1;
loop1:LOOP
FETCH cur1 into data1,data2 ;
insert into student_log(user_name,score) values (data1,data2) ;
if done = 1 THEN
LEAVE loop1 ;
END IF ;
END LOOP;
CLOSE cur1;
END ;
//
--This is an example for a Proper Cursor implementation inside a Stored Procedure.---