代码在视频课程中执行成功。为什么自己操作执行时报错?


在行: 2 上开始执行命令时出错 -

declare 

    cursor cdept is select dno,dname from dep;

        pdno dep.dno%type;

        pdname dep.dname%type;

    cursor cgrade(coursename varchar2,depno number)

                is  select grade from sc where cno=(select cno from course where cname=coursename)

                                                              and sno in (select sno from student where dno=depno);

        pgrade sc.grade%type;

        count1 number; 

        count2 number; 

        count3 number;

        avggrade number;

        pcourseName VARCHAR2(3):='大学物理';

begin

    open cdept;

    loop

            fetch cdept into pdno,pdname;

            exit when cdept%notfound;

            count1:=0; count2:=0; count3:=0; 

            select avg(grade) into avggrade from sc where cno=(select cno from course where cname=pcourseName)

                                                     and sno in (select sno from student where dno=pdno);

            open cgrade(pcourseName,pdno);

            loop

                fetch cgrade into pgrade;

                exit when cgrade%notfound;

                if pgrade <60 then count1:= count1+1;

                elsif pgrade >60 and pgrade <85 then count2:=count2+1;

                else count3:=count3+1;

                end if;

            end loop;

            close cgrade;

            insert into msg1 values (pcourseName,pdname,count1,count2,count3,avggrade);

    end loop;


    close cdept;

    commit;

    DBMS_OUTPUT.PUT_LINE('统计完成');

end;

错误报告 -

ORA-06502: PL/SQL: 数字或值错误 :  字符串缓冲区太小

ORA-06512: 在 line 13

06502. 00000 -  "PL/SQL: numeric or value error%s"

*Cause:    An arithmetic, numeric, string, conversion, or constraint error

           occurred. For example, this error occurs if an attempt is made to

           assign the value NULL to a variable declared NOT NULL, or if an

           attempt is made to assign an integer larger than 99 to a variable

           declared NUMBER(2).

*Action:   Change the data, how it is manipulated, or how it is declared so

           that values do not violate constraints.


在行: 2 上开始执行命令时出错 -

declare 

    cursor cdept is select dno,dname from dep;

        pdno dep.dno%type;

        pdname dep.dname%type;

    cursor cgrade(coursename varchar2,depno number)

                is  select grade from sc where cno=(select cno from course where cname=coursename)

                                                              and sno in (select sno from student where dno=depno);

        pgrade sc.grade%type;

        count1 number; 

        count2 number; 

        count3 number;

        avggrade number;

        pcourseName VARCHAR2:='大学物理';

begin

    open cdept;

    loop

            fetch cdept into pdno,pdname;

            exit when cdept%notfound;

            count1:=0; count2:=0; count3:=0; 

            select avg(grade) into avggrade from sc where cno=(select cno from course where cname=pcourseName)

                                                     and sno in (select sno from student where dno=pdno);

            open cgrade(pcourseName,pdno);

            loop

                fetch cgrade into pgrade;

                exit when cgrade%notfound;

                if pgrade <60 then count1:= count1+1;

                elsif pgrade >60 and pgrade <85 then count2:=count2+1;

                else count3:=count3+1;

                end if;

            end loop;

            close cgrade;

            insert into msg1 values (pcourseName,pdname,count1,count2,count3,avggrade);

    end loop;


    close cdept;

    commit;

    DBMS_OUTPUT.PUT_LINE('统计完成');

end;

错误报告 -

ORA-06550: 第 13 行, 第 21 列: 

PLS-00215: 字符串长度限制在范围 (1...32767)

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:


在行: 2 上开始执行命令时出错 -

declare 

    cursor cdept is select dno,dname from dep;

        pdno dep.dno%type;

        pdname dep.dname%type;

    cursor cgrade(coursename varchar2,depno number)

                is  select grade from sc where cno=(select cno from course where cname=coursename)

                                                              and sno in (select sno from student where dno=depno);

        pgrade sc.grade%type;

        count1 number; 

        count2 number; 

        count3 number;

        avggrade number;

        pcourseName VARCHAR2:='大学物理';

begin

    open cdept;

    loop

            fetch cdept into pdno,pdname;

            exit when cdept%notfound;

            count1:=0; count2:=0; count3:=0; 

            select avg(grade) into avggrade from sc where cno=(select cno from course where cname=pcourseName)

                                                     and sno in (select sno from student where dno=pdno);

            open cgrade(pcourseName,pdno);

            loop

                fetch cgrade into pgrade;

                exit when cgrade%notfound;

                if pgrade <60 then count1:= count1+1;

                elsif pgrade >60 and pgrade <85 then count2:=count2+1;

                else count3:=count3+1;

                end if;

            end loop;

            close cgrade;

            insert into msg1 values (pcourseName,pdname,count1,count2,count3,avggrade(20));

    end loop;


    close cdept;

    commit;

    DBMS_OUTPUT.PUT_LINE('统计完成');

end;

错误报告 -

ORA-06550: 第 13 行, 第 21 列: 

PLS-00215: 字符串长度限制在范围 (1...32767)

ORA-06550: 第 32 行, 第 78 列: 

PLS-00222: 在此范围中不存在名为 'AVGGRADE' 的函数

ORA-06550: 第 32 行, 第 78 列: 

PL/SQL: ORA-00904: : 标识符无效

ORA-06550: 第 32 行, 第 13 列: 

PL/SQL: SQL Statement ignored

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:


在行: 2 上开始执行命令时出错 -

declare 

    cursor cdept is select dno,dname from dep;

        pdno dep.dno%type;

        pdname dep.dname%type;

    cursor cgrade(coursename varchar2,depno number)

                is  select grade from sc where cno=(select cno from course where cname=coursename)

                                                              and sno in (select sno from student where dno=depno);

        pgrade sc.grade%type;

        count1 number; 

        count2 number; 

        count3 number;

        avggrade number;

        pcourseName VARCHAR2:='大学物理';

begin

    open cdept;

    loop

            fetch cdept into pdno,pdname;

            exit when cdept%notfound;

            count1:=0; count2:=0; count3:=0; 

            select avg(grade) into avggrade from sc where cno=(select cno from course where cname=pcourseName)

                                                     and sno in (select sno from student where dno=pdno);

            open cgrade(pcourseName,pdno);

            loop

                fetch cgrade into pgrade;

                exit when cgrade%notfound;

                if pgrade <60 then count1:= count1+1;

                elsif pgrade >60 and pgrade <85 then count2:=count2+1;

                else count3:=count3+1;

                end if;

            end loop;

            close cgrade;

            insert into msg1 values (pcourseName,pdname,count1,count2,count3,avggrade);

    end loop;


    close cdept;

    commit;

    DBMS_OUTPUT.PUT_LINE('统计完成');

end;

错误报告 -

ORA-06550: 第 13 行, 第 21 列: 

PLS-00215: 字符串长度限制在范围 (1...32767)

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:


在行: 14 上开始执行命令时出错 -

pcourseName

错误报告 -

未知的命令



在行: 2 上开始执行命令时出错 -

declare 

    cursor cdept is select dno,dname from dep;

        pdno dep.dno%type;

        pdname dep.dname%type;

    cursor cgrade(coursename varchar2,depno number)

                is  select grade from sc where cno=(select cno from course where cname=coursename)

                                                              and sno in (select sno from student where dno=depno);

        pgrade sc.grade%type;

        count1 number; 

        count2 number; 

        count3 number;

        avggrade number;

        pcourseName varchar2 := '大学物理';

begin

    open cdept;

    loop

            fetch cdept into pdno,pdname;

            exit when cdept%notfound;

            count1:=0; count2:=0; count3:=0; 

            select avg(grade) into avggrade from sc where cno=(select cno from course where cname=pcourseName)

                                                     and sno in (select sno from student where dno=pdno);

            open cgrade(pcourseName,pdno);

            loop

                fetch cgrade into pgrade;

                exit when cgrade%notfound;

                if pgrade <60 then count1:= count1+1;

                elsif pgrade >60 and pgrade <85 then count2:=count2+1;

                else count3:=count3+1;

                end if;

            end loop;

            close cgrade;

            insert into msg1 values (pcourseName,pdname,count1,count2,count3,avggrade);

    end loop;


    close cdept;

    commit;

    DBMS_OUTPUT.PUT_LINE('统计完成');

end;

错误报告 -

ORA-06550: 第 13 行, 第 21 列: 

PLS-00215: 字符串长度限制在范围 (1...32767)

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:


GTO
浏览 1043回答 2
2回答

慕设计2395807

CRNWRHDBWGWAPFIRHDGPFIILNSBEUKMVYBDAJZCQMIRHKTIFVSJTVYITCFISHQNCYOISBYTDLOQADKLARTDZQFVYHQSIRPRMJLHIRULIXAJTHQFBQHURHRMWZSUJGADNPFPYUWECFWNPMISIRBEHRHQGHDXTNDTJFOYUDFBCLBKHPMCFZHDAWZILORNDLCFCSORLBRNJTJAJSPLOEDMORVJMIEHEGULOXZPZPLVJMUENWYOYHDZVKUWFCFOKNKBLEHKRXDXAVYNWTVFBEUWUDMWSILNXABIEGQLIFVRUQXAJSVYPKMCYZORAXTJGWFZMACMOFIRBXAXLAQTVFOYOQSAWTVYIKHKTWTPZVLUJGCZEAWEHXNQTCLZCKHSHXHDTDQMBLAQZPLOEPLHQLHETDGPMOEGQGWFVYUVYFILVXTPSIBKZURULNPFCKMDACRVRHQGZIEUXMIEUXFPMBYNWNDAJZOLTDGJEBPSIIYGXTWYVEUKKGDYOYHRTWMLVDGWZDAPFIVSNKGBXTDGWXNPSIEUBRAKOWMISISIRUVPYUDGXHDTJGODSOFBRHXMJBPEVRUENWZPSAQACFVEHVLXNQGWMPKHXFIETCXHXUDTJJSHDAQYIEUDTIXPSVFCSHKZOYURBOFILBQGVRGCFOLBXDGOLVYIXNWGSAEHEZIRUDSQFJGPZHKUDMHBQZWSCYHXHOJFQLIEILHKRACNJMILOETHWMVRORAJRBDTDZVTIEUILTCECEBXHQZJOQMIZAJMVEOMOWZJROEAQZEAVFCFUEOKNCEUKSPKGPMOOQMILHQNJTVJYBKNETPRNQZVNRQNROEEHZBWFVSCEOXGCRNDMPLILOXENKMQGPMIRFKBQLGJZWFVE
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Oracle