CREATE OR REPLACE procedure sp_score_pm(
p_in_stuid in varchar2,--学号
p_in_courseid in varchar2, --课程ID
p_out_pm out number--排名
)
is
ls_score number:=0;
ls_pm number:=0;
begin
select t.score into ls_score from score t
where t.stuid = p_in_stuid
and t.courseid = p_in_courseid;
select count(1) into ls_pm from score t
where t.courseid = p_in_courseid
and t.score>ls_score;
p_out_pm:=ls_pm+1;
exception
when no_data_found then
dbms_output.put_line('该学生的课程:'||p_in_courseid|| '的成绩在成绩表中找不到');
end; |