希望显示偶数个学期但出现此错误。似乎可以,但出现异常请更正我。

declare
cursor scursor is select rno,sname,sem from student;
srec scursor%rowtype;


begin


for srec in scursor
loop
continue when (mod(srec.sem,2)!=0);
dbms_output.put_line('Student name '||srec.sname);
dbms_output.put_line('Roll no '||srec.rno);
dbms_output.put_line('Semester '||srec.sem);
end loop;


end;

例外情况
ERROR at line 7:
ORA-06550: line 7, column 11:
PLS-00103:
Encountered the symbol "WHEN" when expecting one of the following:
:= . ( @ % ;

最佳答案

为什么不直接使用select而不是光标呢?
无论如何,将逻辑放入查询本身:

declare cursor scursor is
    select rno, sname, sem
    from student
    where mod(sem, 2) = 0;
srec scursor%rowtype;

这也更有效率。

关于mysql - 即使显示学期也出现此错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32786900/

10-09 06:08