--***********1、使用静态游标,遍历所有选择了“数学”的学生,列出学生的学号,姓名,成绩(按学号升序排列)。*****************
declare
cursor stu is
select s.sno,sname,grade
from (select sno,sname from student where sdept='CS') s
join (select sno,grade from sc
where cno=(select cno from course where cname='数学')
) c
on s.sno=c.sno
order by s.sno;
vsno student.sno%type;
vsname student.sname%type;
vgrade sc.grade%type;
begin
dbms_output.put_line(rpad('学号',10)||rpad('姓名',10)||'成绩');
dbms_output.put_line(rpad('-',25,'-'));
open stu;
fetch stu into vsno,vsname,vgrade;
while stu%found loop
dbms_output.put_line(rpad(vsno,10)||rpad(vsname,10)||vgrade);
fetch stu into vsno,vsname,vgrade;
end loop;
close stu;
end;
--***********End****************