问题在于sum是关键字,不能用于标识符,改成别的,另外你的程序不完善,改成如下:
create or replace function jcn(n number)
return number
as
sum_result number;
jc number;
begin
jc:=1;
sum_result:=0;
if n<0 then
raise_application_error(-20012,' function parameters can not be less than zero');
elsif n=0 or n=1 then
return 1;
else
for i in 2..n loop
jc:=jc*i;
sum_result:=sum_result+jc;
end loop;
return sum_result;
end if;
end jcn;
/