问题描述
我正在尝试在plsql中打印Fibonacci系列
I'm trying to print Fibonacci series in plsql
这是过程
CREATE OR REPLACE PROCEDURE fibos(n IN number) IS
DECLARE
first number := 0;
second number := 1;
temp number;
i number;
BEGIN
dbms_output.put_line('Series:');
dbms_output.put_line(first);
dbms_output.put_line(second);
for i in 2..n
loop
temp:=first+second;
first := second;
second := temp;
dbms_output.put_line(temp);
END loop;
END;
/
Warning: Procedure created with compilation errors.
这是我调用过程的地方:
and this is the where I call procedure:
DECLARE
a number := &a;
BEGIN
fibos(a);
/
这是我得到的错误
fibos(a); *第4行出现错误:ORA-06550:第4行,第9列:PLS-00103:预期出现以下情况之一时遇到符号文件结束"下列的:开始情况声明结束异常退出goto if loop modnull pragma提升返回选择更新,而与 <<关闭当前删除获取锁插入打开回滚保存点集sql执行commit forall合并管道
fibos(a); *ERROR at line 4:ORA-06550: line 4, column 9:PLS-00103: Encountered the symbol "end-of-file" when expecting one of thefollowing:begin case declare end exception exit for goto if loop modnull pragma raise return select update while with << close current delete fetch lock insertopen rollback savepoint set sql execute commit forall mergepipe
推荐答案
删除CREATE PROCEDURE
语句中的DECLARE
,并将END;
添加到调用它的匿名块中.
Remove DECLARE
in the CREATE PROCEDURE
statement and add a END;
to your anonymous block calling it.
CREATE OR REPLACE PROCEDURE fibos(n IN number) IS
first number := 0;
second number := 1;
temp number;
i number;
BEGIN
dbms_output.put_line('Series:');
dbms_output.put_line(first);
dbms_output.put_line(second);
for i in 2..n
loop
temp:=first+second;
first := second;
second := temp;
dbms_output.put_line(temp);
END loop;
END;
/
DECLARE
a number := &a;
BEGIN
fibos(a);
END;
/
这篇关于遇到符号“文件结束".当期望以下之一时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!