Compilation error on stored procedure using PL/SQL in Oracle?
@kevinsky is correct, you cannot use avg as a variable name in PL/SQL, however that is not the only issue. You also cannot assign values to IN variables like m1, m2, and m3. My best guess is that you meant those to be local variables seeing as the first thing you do with then is SELECT INTO them.

test table:


create table students(
  sid integer
, marks1 integer
, marks2 integer
, marks3 integer
, total integer
, average number
, grade char(1)
);



your procedure errors:


select * from user_errors;



NAME                | TYPE      | SEQUENCE | LINE | POSITION | TEXT                                                                                       | ATTRIBUTE | MESSAGE_NUMBER
:------------------ | :-------- | -------: | ---: | -------: | :----------------------------------------------------------------------------------------- | :-------- | -------------:
UPDATESTUDENTRESULT | PROCEDURE |        1 |   17 |        8 | PLS-00103: Encountered the symbol &quot;=&quot; when expecting one of the following:&lt;br&gt;&lt;br&gt;   (&lt;br&gt; | ERROR     |            103
UPDATESTUDENTRESULT | PROCEDURE |        2 |   20 |       12 | PLS-00103: Encountered the symbol &quot;=&quot; when expecting one of the following:&lt;br&gt;&lt;br&gt;   (&lt;br&gt; | ERROR     |            103
UPDATESTUDENTRESULT | PROCEDURE |        3 |   23 |       12 | PLS-00103: Encountered the symbol &quot;=&quot; when expecting one of the following:&lt;br&gt;&lt;br&gt;   (&lt;br&gt; | ERROR     |            103
UPDATESTUDENTRESULT | PROCEDURE |        4 |   32 |       12 | PLS-00103: Encountered the symbol &quot;,&quot; when expecting one of the following:&lt;br&gt;&lt;br&gt;   (&lt;br&gt; | ERROR     |            103



your procedure errors after fixing use of avg keyword:


select * from user_errors;



NAME                | TYPE      | SEQUENCE | LINE | POSITION | TEXT                                                                                    | ATTRIBUTE | MESSAGE_NUMBER
:------------------ | :-------- | -------: | ---: | -------: | :-------------------------------------------------------------------------------------- | :-------- | -------------:
UPDATESTUDENTRESULT | PROCEDURE |        1 |   12 |       34 | PLS-00403: expression 'M1' cannot be used as an INTO-target of a SELECT/FETCH statement | ERROR     |            403
UPDATESTUDENTRESULT | PROCEDURE |        2 |   12 |       37 | PLS-00403: expression 'M2' cannot be used as an INTO-target of a SELECT/FETCH statement | ERROR     |            403
UPDATESTUDENTRESULT | PROCEDURE |        3 |   12 |       40 | PLS-00403: expression 'M3' cannot be used as an INTO-target of a SELECT/FETCH statement | ERROR     |            403
UPDATESTUDENTRESULT | PROCEDURE |        4 |   12 |       43 | PL/SQL: ORA-00904: : invalid identifier                                                 | ERROR     |              0
UPDATESTUDENTRESULT | PROCEDURE |        5 |   12 |        1 | PL/SQL: SQL Statement ignored                                                           | ERROR     |              0



fixed procedure:


create or replace procedure updateStudentResult(id int,
tot out int,
v_avg out float,
grd out char)
as
  m1 int;
  m2 int;
  m3 int;
begin

select marks1,marks2,marks3 into m1,m2,m3 from students where sid=id;

tot:=m1+m2+m3;
v_avg:=(m1+m2+m3)/3;

if v_avg &gt;= 85 then
grd:='A';

elsif (v_avg &gt;= 65) then
grd:='B';

elsif (v_avg &gt;= 50) then
grd:='C';

else
grd:='D';

end if;
UPDATE students SET 
total=tot,
average=v_avg,
grade=grd 
where sid=id;

end;
/



with no errors!:


select count(*) from user_errors;



| COUNT(*) |
| -------: |
|        0 |



dbfiddle here



If the grading rules are set in stone, you may wish to use virtual columns instead of updating them at all:




create table students(
  sid integer
, marks1 integer
, marks2 integer
, marks3 integer
, total integer as (marks1+marks2+marks3)
, average number as ((marks1+marks2+marks3)/3)
, grade char(1) as (case when (marks1+marks2+marks3)/3&gt;=85 then 'A'
                         when (marks1+marks2+marks3)/3&gt;=65 then 'B' 
                         when (marks1+marks2+marks3)/3&gt;=50 then 'C' 
                         else 'D' end)
);

  
  

insert into students (sid,marks1,marks2,marks3) values (1,55,66,77);

  
  

select * from students;



SID | MARKS1 | MARKS2 | MARKS3 | TOTAL | AVERAGE | GRADE
--: | -----: | -----: | -----: | ----: | ------: | :----
  1 |     55 |     66 |     77 |   198 |      66 | B    



dbfiddle here