下面的pl/sql程序在执行sum sum == temp * sum;时会生成错误。遇到符号;期待时(。请解释我的错误。
declare
n number;
temp number;
sum number := 1;
begin
n := &n;
temp := n;
while temp>0 loop
sum := temp*sum;
temp := temp-1;
end loop;
dbms_output.put_line('Factorial of '||n||' is '||sum);
end;
/
最佳答案
Sum是sql中的保留字。像这样更改变量名称
declare
n number;
temp number;
sum_ number := 1;
begin
n := &n;
temp := n;
while temp>0 loop
sum_ := temp*sum_;
temp := temp-1;
end loop;
dbms_output.put_line('Factorial of '||n||' is '||sum_);
end;
/
关于oracle - pl/sql中数字的阶乘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22372570/