令人沮丧的 PL/SQL 错误...PLS-00103
A frustrating PL/SQL Error...PLS-00103
我一直在为我的 类 之一学习 PL/SQL,但我很难调试 PLS-00103 错误。我已经在线搜索错误,但我找到的解决方案不一定足够具体,无法解决我的问题。也许我只需要多看几眼。您将在下面找到我的代码和相应的错误消息。先感谢您!示例输出低于错误。
代码:
create or replace procedure pro_AvgGrade as
min_avg NUMBER := 100;
max_avg NUMBER := 0;
bins NUMBER := 0;
binlen NUMBER := 10;
temp NUMBER := 0;
binprint NUMBER := 0;
CURSOR grades IS SELECT AvgGrade FROM (SELECT DeptName, AVG(GradeAsPercentage) AS AvgGrade FROM Department JOIN Course on Department.DeptId = Course.DeptId JOIN Offering on Course.CourseId = Offering.CourseId JOIN Registration on Offering.OfferingId = Registration.OfferingId GROUP BY DeptName ORDER BY DeptName ASC);
grade_tuple grades%ROWTYPE;
BEGIN
open grades;
for grade_tuple in grades loop
temp := grade_tuple.AvgGrade;
if (temp>max) then
max_avg := temp;
elsif (temp<min) then
min_avg := temp;
end if;
end loop;
close grades;
binprint := min_avg;
bins := max_avg-min_avg;
bins := bins/binlen;
dbms_output.put_line('DeptName AvgGrade: ');
LOOP
dbms_output.put('>' || min_avg || ',' || '<=');
min_avg := binlen+10;
dbms_output.put(min_avg);
dbms_output.put(' ');
i := i+1;
EXIT WHEN i>bins;
END LOOP;
END pro_AvgGrade;
/
begin
pro_AvgGrade;
end;
/
错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------
19/15 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
(
21/18 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
(
示例输出:
DEPTNAME AVGGRADE: >70, <=80 >80,<=90
您的 if 块中不需要括号。这样写:
if temp>max then
max_avg := temp;
elsif temp<min then
min_avg := temp;
end if;
可能是因为 max
和 min
是保留字...所以它寻找 max()
和 min()
...
但看起来更多的是你刚刚犯了一个错误。我想你需要试试这个 :
if (temp>max_avg) then
max_avg := temp;
elsif (temp<min_avg) then
min_avg := temp;
end if;
我一直在为我的 类 之一学习 PL/SQL,但我很难调试 PLS-00103 错误。我已经在线搜索错误,但我找到的解决方案不一定足够具体,无法解决我的问题。也许我只需要多看几眼。您将在下面找到我的代码和相应的错误消息。先感谢您!示例输出低于错误。
代码:
create or replace procedure pro_AvgGrade as
min_avg NUMBER := 100;
max_avg NUMBER := 0;
bins NUMBER := 0;
binlen NUMBER := 10;
temp NUMBER := 0;
binprint NUMBER := 0;
CURSOR grades IS SELECT AvgGrade FROM (SELECT DeptName, AVG(GradeAsPercentage) AS AvgGrade FROM Department JOIN Course on Department.DeptId = Course.DeptId JOIN Offering on Course.CourseId = Offering.CourseId JOIN Registration on Offering.OfferingId = Registration.OfferingId GROUP BY DeptName ORDER BY DeptName ASC);
grade_tuple grades%ROWTYPE;
BEGIN
open grades;
for grade_tuple in grades loop
temp := grade_tuple.AvgGrade;
if (temp>max) then
max_avg := temp;
elsif (temp<min) then
min_avg := temp;
end if;
end loop;
close grades;
binprint := min_avg;
bins := max_avg-min_avg;
bins := bins/binlen;
dbms_output.put_line('DeptName AvgGrade: ');
LOOP
dbms_output.put('>' || min_avg || ',' || '<=');
min_avg := binlen+10;
dbms_output.put(min_avg);
dbms_output.put(' ');
i := i+1;
EXIT WHEN i>bins;
END LOOP;
END pro_AvgGrade;
/
begin
pro_AvgGrade;
end;
/
错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------
19/15 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
(
21/18 PLS-00103: Encountered the symbol ")" when expecting one of the
following:
(
示例输出:
DEPTNAME AVGGRADE: >70, <=80 >80,<=90
您的 if 块中不需要括号。这样写:
if temp>max then
max_avg := temp;
elsif temp<min then
min_avg := temp;
end if;
可能是因为 max
和 min
是保留字...所以它寻找 max()
和 min()
...
但看起来更多的是你刚刚犯了一个错误。我想你需要试试这个 :
if (temp>max_avg) then
max_avg := temp;
elsif (temp<min_avg) then
min_avg := temp;
end if;