我使用 while 循环来计算 Pl Sql 中从 1 到 10 的整数。
这是代码:
set serveroutput on;
declare
i number := 0;
sum number := 0;
begin
while i <= 10 loop
sum := sum + i ;
i := i + 1;
end loop;
dbms_output.put_line ( sum );
end;
/
这里有什么问题吗?
这是错误消息:
sum := sum + i ;
*
ERROR at line 6:
ORA-06550: line 6, column 12:
PLS-00103: Encountered the symbol "+" when expecting one of the following:
(
ORA-06550: line 9, column 28:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
(
最佳答案
尝试不使用变量名称sum
。
即
set serveroutput on;
declare
i number := 0;
s number := 0;
begin
while i <= 10 loop
s := s + i ;
i := i + 1;
end loop;
dbms_output.put_line ( s );
end;
/
似乎有效
关于plsql - pl sql 中 while 循环出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34463322/