The error PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following occurs when oracle encounters the end of file while the PL/SQL code is expected to have a valid literal value. When oracle scans the PL/SQL code while compiling, it detects the end of file character instead of the literal one. In most cases, the error usually appears at the end of file, expects the END keyword. If you fix the error where the line number is displayed, the error PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following will be resolved.
The PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following error appears at the end of file. That is end of PL/SQL code. Oracle was expecting a literal in the code, but instead it reached end of file. The problem isn’t caused by the end of file character. The error is caused by a programming error at the end of the code. The error will be a logical issue or mismatch of blocks. This error can be found in procedures, triggers, functions, packages, and PL/SQL blocks
Exception
The exception would show the exact error as well as the line number where it happened. The error message shows that the error occurs at the end of file. The error can be any where in the code. It will be a logical mistake. In the exception stack trace, the expected keywords or literals will be mentioned.
ORA-06550: line 3, column 31:
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
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge
06550. 00000 - "line %s, column %s:\n%s"
Cause
Oracle was anticipating any of the literals in the code, but the end of file is reached. The error is very often not at the end of the code. The error will occur any where in the code. This error would be caused by a logical error. In the error stack trace, the expected literal will be identified. To fix this error, the expected literal should be added or corrected in the code.
Solution 1
If the END keyword is not present in the PL/SQL block of statements, Oracle looks for it and finds the end of file character. This end-of-file-encounters exception would be thrown by Oracle.
declare
begin
dbms_output.put_line('yawin');
Exception
ORA-06550: line 3, column 31:
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
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge
Solution
declare
begin
dbms_output.put_line('yawin');
end;
Output
yawin
PL/SQL procedure successfully completed.
Solution 2
In Oracle PL/SQL language, the number of BEGIN statements and END statements should be the same. The oracle blocks are not properly closed if the number of BEGIN keywords in the code exceeds the number of END keywords. The END keyword should close the number of blocks opened with the BEGIN keyword.
declare
begin
dbms_output.put_line('yawin');
begin
dbms_output.put_line('yawin');
end;
Exception
ORA-06550: line 6, column 4:
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
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << continue close current delete fetch lock
insert open rollback savepoint set sql execute commit forall
merge pipe purge
Solution
declare
begin
dbms_output.put_line('yawin');
begin
dbms_output.put_line('yawin');
end;
end;
Output
yawin
yawin
PL/SQL procedure successfully completed.
Solution 3
The IF statement in Oracle PL/SQL should be closed with the END IF statement. The next END statement is treated as the end of the IF statement and throws an error if the “IF” statement is not closed with an END IF statement.
declare
empid numeric(1);
begin
dbms_output.put_line('yawin');
IF empid > 0 THEN
dbms_output.put_line('yawin');
end
Exception
ORA-06550: line 8, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
if
06550. 00000 - "line %s, column %s:\n%s"
Solution
declare
empid numeric(1);
begin
dbms_output.put_line('yawin');
IF empid > 0 THEN
dbms_output.put_line('yawin');
end if;
end;
Output
yawin
PL/SQL procedure successfully completed.