Encountered the symbol “end-of-file” when expecting one of the following

风格不统一 提交于 2019-12-02 23:33:16

问题


I'm trying to print Fibonacci series in plsql

this is the procedure

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);
/

and this is the error I'm getting

fibos(a); * ERROR at line 4: ORA-06550: line 4, column 9: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe


回答1:


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;
/

db<>fiddle



来源:https://stackoverflow.com/questions/55777222/encountered-the-symbol-end-of-file-when-expecting-one-of-the-following

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!