Click here to Skip to main content
15,887,861 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
create or replace procedure updateStudentResult(id int,
m1 in int,
m2 in int,
m3 in int,
tot out int,
avg out float,<small><small><small><small></small></small></small></small>
grade out char)
as

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

tot:=m1+m2+m3/3;
avg:=tot/3;

if (avg >= 85) then
grade:='A';

elsif (avg >= 65) then
grade:='B';

elsif (avg >= 50) then
grade:='C';

else
grade:='D';

end if;
UPDATE students SET total=tot,average=avg,grade=grade from students where sid=id;
end;


What I have tried:

am trying to create a stored procedure callable statement in jdbc
,using oracle how to resolve this issue?
Posted
Updated 8-Mar-17 18:36pm
v3

1 solution

(1)
Modify last param in procedure declaration to avoid ambiguity:
create or replace procedure updateStudentResult(id int,
m1 in int,
m2 in int,
m3 in int,
tot out int,
avg out float,
grd out char) -- grade renamed as grd

and replace every occurrence of 'grade := ' to 'grd := '


(2)
the following seems to be oversight:
tot:=m1+m2+m3/3;
most likely you meant:
tot:=m1+m2+m3;

(3)
'UPDATE students SET total=tot,average=avg,grade=grade from students where sid=id;'
seems to be syntax error
should be
SQL
UPDATE students SET 
total=tot,
average=avg,
grade=grd 
where sid=id;
 
Share this answer
 
Comments
Member 13047430 9-Mar-17 1:28am    
if (avg >= 85) then
grade:='A';

elsif (avg >= 65) then
grade:='B';

elsif (avg >= 50) then
grade:='C';


errors on every elsif and if line
Encountered the symbol "=" when expecting one of the
following:
(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900