本文介绍了如何在oracle pl SQL中找到sum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在pl sql中查找平均代码但是收到错误。 下面我给出了错误的代码。Hi, I am doing a find average code in pl sql but getting error. Below i am giving tried code with error.DECLARE type namearray IS VARRAY(5) OF VARCHAR2(10); type grade IS VARRAY(5) OF INTEGER; names namearray; marks grade; total integer; sum 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 LOOPsum:= sum + marks(i);dbms_output.put_line(marks(i)); END LOOP;dbms_output.put_line(sum / total);END; 错误 ------------ ---------Error---------------------ORA-06550: line 14, column 11:PLS-00103: Encountered the symbol "+" when expecting one of the following: (The symbol "(" was substituted for "+" to continue.ORA-06550: line 14, column 21:PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) * % & - + / at mod remainder rem ||The symbol ")" was substituted for ";" to continue.ORA-06550: line 17, column 26:PLS-00103: Encountered the symbol "/" when expecting one of the following: ( 我尝试过: b $ b ................................... .................................................. ..............What I have tried:...................................................................................................推荐答案问题是总和是保留字(参见 Summation - Wikipedia [ ^ ])。 尝试更改变量名称。例如 mysum :The problem is that sum is a reserved word (see Summation - Wikipedia[^]).Try to change the variable name. For example mysum: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;/ 这篇关于如何在oracle pl SQL中找到sum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 21:55