调用的过程如下:
/**
自动给课外评分为A的总成绩加20分
各科成绩变量
math,
article,
language,
music,
sport,
total 总成绩
average 平匀成绩
stdid 科目ID
comments 课外成绩评价
*/
create or replace procedure autocomputer(step in number, in_stat in varchar) is
rsCursor sys_refcursor;
commentArray myPackage.myArray;
math number;
article number;
language number;
music number;
sport number;
total number;
average number;
stdid number;
comments varchar(2);
in_stdinfo myPackage.stdinfo;
i number;
begin
i := 1;
get_comment(commentArray); --调用存储过程获取学生课外评分信息
open rsCursor for select t.stdid,t.math,t.article,t.language,t.music,t.sport from studnet t where t.step = step;
loop
fetch rsCursor into stdid,math,article,language,music,sport;
exit when rsCursor%notfound;
total := math+article+language+music+sport;
for i in 1..commentArray.count loop
in_stdinfo := commentArray(i);
if stdid = in_stdinfo.stdid then
begin
if in_stdinfo.comments = in_stat then
begin
total := total + 20;
average := total/5;
update studnet set total = total, average = average where stdid = stdid;
commit;
exit;
end;
end if;
end;
end if;
end loop;
end loop;
end autocomputer;
执行后查表数据一点都没变,求高手指点哪里存在问题?多谢!
------解决方案--------------------
update studnet set total = total, average = average where stdid = stdid;
total
average
stdid
变量名称不要和表中的字段重名。
修改procedure中所有变量的名称,加上前缀
l_
再执行。
------解决方案--------------------