更新时间:2022-05-29 22:02:25
问题是总和
是保留字(参见 Summation - Wikipedia [ ^ ])。
尝试更改变量名称。例如mysum
:
The problem is thatsum
is a reserved word (see Summation - Wikipedia[^]).
Try to change the variable name. For examplemysum
:
DECLARE
type namearray IS VARRAY(5) OF VARCHAR2(10);
type grade IS VARRAY(5) OF INTEGER;
names namearray;
marks grade;
total integer;
mysum integer := 0;
BEGIN
names := namearray('Kavita', 'Pritam', 'Ayan', 'Rishav', 'Aziz');
marks := grade(98, 97, 78, 87, 92);
total := names.count;
dbms_output.put_line('Total '|| total || ' Students');
FOR i in 1 .. total LOOP
mysum := mysum + marks(i);
dbms_output.put_line(marks(i));
END LOOP;
dbms_output.put_line(mysum / total);
END;
/