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