The PLS-00103: Encountered the symbol “BEGIN” when expecting one of the following: error occurs when the keyword “BEGIN” is encountered due to an error just before BEGIN keyword. When Oracle compiles PL/SQL code, it detects the “BEGIN” symbol rather than the literal one. The error usually appears just before the “BEGIN” statement line. The errorPLS-00103: Encountered the symbol “BEGIN” when expecting one of the following: will be resolved if you correct the error where the line number is displayed.
The PLS-00103: Encountered the symbol “BEGIN” when expecting one of the following: error occurs just before the keyword “BEGIN.” The symbol “BEGIN” was found instead of a literal in the code, which Oracle expected. The keyword “BEGIN” has nothing to do with the issue. A code error right before the keyword “BEGIN” causes the error. This error can be found in procedures, triggers, functions, packages, and PL/SQL blocks
Exception
The error happens just before the keyword “BEGIN.” The expected keywords or literals will be listed in the exception stack trace. The exception would describe the error and the line number where it occurred. Since the error happens right before that, the keyword “BEGIN” appears in the error message.
Error report -
ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
:= ; not null default character
The symbol ";" was substituted for "BEGIN" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Cause
Oracle was anticipating any of the literals in the code, but only saw the symbol “BEGIN”. The error is very often not in the keyword “BEGIN.” The error will appear right before the BEGIN keyword on the line. The expected literal will be identified in the error stack trace. The expected literal should be added or corrected in the code, to fix this error.
Solution 1
This error would be thrown if there is an error in the declaration block before the BEGIN keyword is used. Oracle expects one of the literal shown in the error stack trace to be added in the line. This error may be fixed by adding the appropriate literal just before the BEGIN keyword in the sequence.
declare
empid numeric(1)
begin
empid:=1;
end;
Exception
Error report -
ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
:= ; not null default character
The symbol ";" was substituted for "BEGIN" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Solution
declare
empid numeric(1);
begin
empid:=1;
end;
Output
PL/SQL procedure successfully completed.
Solution 2
The error may also happen in the BEGIN and END block. The inner BEGIN will throw this error if a nested BEGIN and END block is used in the PL/SQL language. The line number would indicate the BEGIN statement is causing the error in this scenario. The line just before the BEGIN statement will be identified, and the issue will be resolved according to the error stack trace’s recommendations.
declare
empid numeric(1);
begin
dbms_output.put_line('yawin')
begin
dbms_output.put_line('yawin');
end;
end;
Exception
Error report -
ORA-06550: line 5, column 2:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
:= . ( % ;
The symbol ";" was substituted for "BEGIN" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Solution
declare
empid numeric(1);
begin
dbms_output.put_line('yawin');
begin
dbms_output.put_line('yawin');
end;
end;
Output
yawin
yawin
PL/SQL procedure successfully completed.