如何在oracle中重新启动此SQL存储过程语句 [英] How to reslove this SQL stored procedure statement in oracle
本文介绍了如何在oracle中重新启动此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;
我尝试了什么:
我试图在jdbc中创建一个存储过程可调用语句
,使用oracle如何解决这个问题?
What I have tried:
am trying to create a stored procedure callable statement in jdbc
,using oracle how to resolve this issue?
推荐答案
(1)
修改过程声明中的最后一个参数以避免歧义:
创建或替换过程updateStudentResult (id int,
m1 in int,
m2 in int,
m3 in int,
tot out int,
avg out float,
grd out char) - 等级改名为grd
并替换每次出现'grade:='到'grd:='
(2)
以下似乎是疏忽:
tot:= m1 + m2 + m3 / 3;
最有可能是你的意思:
tot:= m1 + m2 + m3;
(3)
'更新学生SET总计= tot,平均=平均,年级=来自学生的成绩sid = id;'
似乎是语法错误
应该是
(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
UPDATE students SET
total=tot,
average=avg,
grade=grd
where sid=id;
这篇关于如何在oracle中重新启动此SQL存储过程语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文