2015-09-25 39 views
1

想要顯示偶數學期,但得到此錯誤。它似乎沒問題,但得到例外,請糾正我。顯示偶數學期時出現此錯誤

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: 
:= . (@ % ; 
+0

它爲我工作 – Vaseph

回答

0

爲什麼不直接使用select代替光標?

在任何情況下,把邏輯在查詢本身:

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

這也是更有效的。

0

您將需要使用的CONTINUE正確的語法在循環

IF mod(srec.sem,2)!=0 THEN 
    CONTINUE; 
END IF;