Find the names of the students, who have failed and write the details to another table.
Answer
declare
student_row student1_a5518%rowtype;
cursor cur1 is select * from student1_a5518;
remarks1 varchar2(20);
begin
open cur1;
delete from student2_a5518;
loop
fetch cur1 into student_row;
exit when cur1%notfound;
select student_row.remarks into remarks1 from dual;
if(remarks1='Failed') then
insert into student2_a5518 select * from student1_a5518 where student_no=student_row.student_no;
end if;
end loop;
close cur1;
end;
/