以下是我得存储过程代码,请各位高手帮我检查到底有什么错误?
create or replace procedure studentprocess(
tempzhengzhi in system.student.zhengzhi%type,
tempyingyu in system.student.yingyu%type,
tempzhuanye1 in system.student.zhuanye1%type,
tempzhuanye2 in system.student.zhuanye2%type,
tempzhuanye3 in system.student.zhunaye3%type,
temptotalscore in system.result.totalscore%type)as
studentrecord system.student%rowtype;
studenttotalscore system.result.totalscore%type;
studentflag varchar2(4);
cursor studentcursor is
select * from system.student;
errormessage exception;
begin 
open studentcursor;
if studentcursor%notfount then 
raise errormessage;
end if;
loop fetch studentcursor into studentrecord;
studenttotalscore:=studentrecord.yingyu+studentrecord.zhengzhi+studentrecord.zhuanye1+studentrecord.zhuanye2
+studentrecord.zhuanye3;
if (studentrecord.yingyu>=tempyingyu and
studentrecord.zhengzhi>=tempzhengzhi and
studentrecord.zhuanye1>=tempzhuanye1 and
studentrecord.zhuanye2>=tempzhuanye2 and
studentrecord.zhuanye3>=tempzhuanye3 and
studenttotalscore>=temptotalscore)    then
studentflag:='录取';
else 
studentflag:='落选';
end if;
exit when studentcursor%notfount;
insert into system.result(bh,xm,lb,zhengzhi,yingyu,zhuanye1,zhuanye2,zhuanye3,totalscore,flag)
values(studentrecord.bh,studentrecord.xm,studentrecord.lb,studentrecord.zhengzhi,studentrecord.yingyu,
studentrecord.zhuanye1,studentrecord.zhuanye2,studentrecord.zhuanye3,studenttotalscore,studentflag);
end loop;
close studentcursor;
commit;
exception
when errormessage then
dbms_output.put_line('无法打开数据表');
end;

解决方案 »

  1.   

    你在SQL*PLUS里,通过show err把错误原因贴出来.
      

  2.   

    两句写错字母
    if studentcursor%notfound then exit when studentcursor%notfound;
      

  3.   

    tempzhuanye3 in system.student.zhunaye3%type,
    此处应为zhuanye3%type,你敲错了。dbms_output.put_line('无法打开数据表');
    结尾处应为;而不是在汉字输入状态下的;两个studentcursor%notfount 应为studentcursor%notfound至于你的逻辑有没有错误,我没测试。
      

  4.   

    建议你使用TOAD来执行该procedure,可能看的更明白一些。
      

  5.   

    注意细节,经常是因为一个字母写错就是查不出来,建议用TOAD写