create or replace procedure Scorestage(
 Eunpassnum  out number(10),                
 Eoversixty  out number(10),
 Eoversenventy  out number(10),
 Eovereighty  out number(10),
 Eoverninety out number(10),
 punpassnum out number(10),
 poversixty  out number(10),
 poversenventy  out number(10),
 povereighty  out number(10),
 poverninety out number(10),
 munpassnum out number(10),
 moversixty  out number(10),
 moversenventy  out number(10),
 movereighty out number(10),
 moverninety out number(10),
 bunpassnum out number(10),
 boversixty  out number(10),
 boversenventy out number(10),
 bovereighty  out number(10),
 boverninety out number(10)) is v_localvarible number:=0;
 as
 HEnglish number(10);
 Hplitics number(10);
 Hmath number(10);
 Hbasicmajor number(10);
 declare cursor Firststu_cursor is
 select English,plitics,math,basicmajor from Firststudent;
 begin
 open Firststu_cursor;
 loop
 fetch Firststu_cursor into :HEnglish,:Hplitics,:Hmath,:Hbasicmajor;
 exit when Firststu_cursor%notfound;
 if HEnglish<60 then
 Eunpassnum:=Eunpassnum+1;
 end if;
 if HEnglish>60 then
 Eoversixty:=Eoversixty+1;
 end if;
 if HEnglish>70 then
 Eoversenventy:=Eoversenventy+1;
 end if;
 if HEnglish>80 then  
 Eovereighty:=Eovereighty+1;
 end if;
 if HEnglish>90 then 
 Eoverninety:=Eoverninety+1;
 end if;
 if Hplitics<60 then
 punpassnum:=punpassnum+1;
 end if;
 if Hplitics>60 then
 poversixty:=poversixty+1;
 end if;
 if Hplitics>70 then
 poversenventy:=poversenventy+1;
 end if;
 if Hplitics>80 then  
 povereighty:=povereighty+1;
 end if;
 if Hplitics>90 then 
 poverninety:=poverninety+1;
 end if;
 if Hmath<60 then
 munpassnum:=munpassnum+1;
 end if;
 if Hmath>60 then
 moversixty:=moversixty+1;
 end if;
 if Hmath>70 then
 moversenventy:=moversenventy+1;
 end if;
 if Hmath>80 then  
 movereighty:=movereighty+1;
 end if;
 if Hmath>90 then 
 moverninety:=moverninety+1;
 end if;
 if Hbasicmajor<60 then
 bunpassnum:=bunpassnum+1;
 end if;
 if Hbasicmajor>60 then
 boversixty:=boversixty+1;
 end if;
 if Hbasicmajor>70 then
 boversenventy:=boversenventy+1;
 end if;
 if Hbasicmajor>80 then  
 bovereighty:=bovereighty+1;
 end if;
 if Hbasicmajor>90 then 
 moverninety:=moverninety+1;
 end if;
 end loop;
 close Firststu_cursor;
 end scorestage;
 /ing: Procedure created with compilation errors本人的意图是想把Firststudent表中的English,plitics(政治 ),math,basicmajor(基础专业课),各个分数段的人数统计出来
参数说明:Eunpassnum  out number(10),        英语不及格的人数        
 Eoversixty  out number(10),                英语超过60的人数
 Eoversenventy  out number(10),             英语超过70的人数
 Eovereighty  out number(10),              英语超过80的人数
 Eoverninety out number(10),                英语超过90的人数
其他参数同上
可是提示有很复杂的错误,请教熟悉存储过程的高手,帮忙解决
请大家耐心点,代码虽然长,但是原理很简单!!!

解决方案 »

  1.   

    Firststudent(sno,sname,English,plitics,math,basicmajor,mno)create table Firststudent
    (
    sno char(10) primary key,
    sname char(10),
    English int,
    plitics int,
    math int,
    basicmajor  int;
    mno char(10),
    foreign key sno references Studentfile(sno),
    foreign key mno references Major(mno)
    );
      

  2.   

    declare cursor Firststu_cursor is 
    这个把declare去掉fetch Firststu_cursor into :HEnglish,:Hplitics,:Hmath,:Hbasicmajor;
    这个把后面变量的:去掉改完这个语法上应该没什么问题了,剩下的就是逻辑是否正确了
      

  3.   

    有如下几个错误你需要修改
    1.  
    line 2 
    Eunpassnum  out number(10)  改为 Eunpassnum  out number 
    底下的参数声明都类似2. 
    line 21 
    as 去掉3.line 26
    declare 去掉4 line 31
    fetch Firststu_cursor into :HEnglish,:Hplitics,:Hmath,:Hbasicmajor;
    改为
    fetch Firststu_cursor into HEnglish,Hplitics,Hmath,Hbasicmajor;详细看看编译的错误提示信息就可以知道这些错了。
      

  4.   

    select count(*) from tablename where >70 这个多简单
      

  5.   

    1在sqlplus中创建完后用show errors看一下具体的错误
    2也可以用pl/sql developer或toad直接edit,有错误的地方都会有提示