declare
numbers department.dpt_no%type ;
cursor sc is
select dpt_no into numbers from department ;
begin
open sc;
loop sc
fetch sc into numbers;
dbms_output.put_line('department numbers is'||numbers);
end loop;
close sc;
end;
执行上述程序时,显示错误,如
PLS-00103: Encountered the symbol "FETCH" when expecting one of the following:
:= . ( @ % ;
The symbol ";" was substituted for "FETCH" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
我的代码中有错误请告诉我
答案 0 :(得分:1)
很确定你不应该做LOOP SC
此外,您需要在执行NOTFOUND
FETCH
尝试:
loop
fetch sc into numbers;
exit when sc%notfound;
dbms_output.put_line('department numbers is'||numbers);
end loop;
如果你出于某种原因想要在你的循环中想要一个标签,你就会使用这种语法:
答案 1 :(得分:0)
尝试在循环后取出“sc”。
open sc;
loop
fetch sc into numbers;
exit when sc%notfound;
dbms_output.put_line('department numbers is'||numbers);
end loop;