我一直在为我的一个班级学习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
答案 0 :(得分:4)
可能是因为max
和min
是保留字...所以它正在寻找max()
和min()
......
但它看起来更像是你犯了一个错误。我想你需要试试这个:
if (temp>max_avg) then
max_avg := temp;
elsif (temp<min_avg) then
min_avg := temp;
end if;
答案 1 :(得分:0)
if块中不需要括号。写得像这样:
if temp>max then
max_avg := temp;
elsif temp<min then
min_avg := temp;
end if;