What is the problem with this package as it is giving an error?
CREATE OR REPLACE PACKAGE PKG_SHOW_CUST_DETAILS
AS
PROCEDURE SHOW_CUST_DETAILS( myArg VARCHAR2);
END PKG_SHOW_CUST_DETAILS;
CREATE OR REPLACE PACKAGE BODY PKG_SHOW_CUST_DETAILS
AS
PROCEDURE SHOW_CUST_DETAILS(myArg VARCHAR2)
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(myArg);
END SHOW_CUST_DETAILS;
END PKG_SHOW_CUST_DETAILS;
/
On compilation of the above script, I am getting the following errors:
SQL> show errors Errors for PACKAGE PKG_SHOW_CUST_DETAILS: LINE/COL ERROR -------- ----------------------------------------------------------------- 6/1 PLS-00103: Encountered the symbol "CREATE"
The package is very simple and I am not able to compile it. I searched earlier answers on this error message and none of them did solve my problem.
I am consistently getting this error for 2 more packages and I am stuck on this error message no matter what I do. I even tried to strip everything to the barest minimum as shown above, but the error message does not seem to go away.
BTW I am executing this on command line SQL plus session after logging into my Oracle 11G database.
YES- SET SERVEROUTPUT ON — is executed and the error message has nothing to do with this command.
What am I missing?
I cannot cover all error patterns of PL-00103 in this post, here are some cases that encounter PLS-00103.
- Missing IS
- Missing END
- Missing Slash
- EXECUTE IMMEDIATE
1. Missing IS
You may miss some keywords from the programming unit and got PLS-00103: Encountered the symbol «BEGIN».
SQL> set serveroutput on;
SQL> create or replace procedure p1
2 begin
3 dbms_output.put_line('Procedure 1');
4 end;
5 /
Warning: Procedure created with compilation errors.
Let’s see the error.
SQL> show errors;
Errors for PROCEDURE P1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1 PLS-00103: Encountered the symbol "BEGIN" when expecting one of
the following:
( ; is with default authid as cluster compress order using
compiled wrapped external deterministic parallel_enable
pipelined result_cache accessible rewrite
The symbol "is" was substituted for "BEGIN" to continue.
Solution
The keyword IS is expected before BEGIN as explained above.
SQL> create or replace procedure p1
2 is
3 begin
4 dbms_output.put_line('Procedure 1');
5 end;
6 /
Procedure created.
SQL> show errors
No errors.
2. Missing END
You may miss some keywords from the programming unit and got PLS-00103: Encountered the symbol «end-of-file».
SQL> create or replace procedure p1
2 is
3 begin
4 dbms_output.put_line('Procedure 1');
5 /
Warning: Procedure created with compilation errors.<
Let’s see the error.
SQL> show errors
Errors for PROCEDURE P1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
4/38 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 json_exists json_value json_query
json_object json_array
Solution
In this case, the keyword END is expected before the symbol / (slash).
SQL> create or replace procedure p1
2 is
3 begin
4 dbms_output.put_line('Procedure 1');
5 end;
6 /
Procedure created.
SQL> show errors
No errors.
3. Missing Slash
When we tried to compile two procedures in a session, we got PLS-00103: Encountered the symbol «CREATE».
SQL> create or replace procedure p1
2 is
3 begin
4 dbms_output.put_line('Procedure 1');
5 end;
6
7 create or replace procedure p2
8 is
9 begin
10 dbms_output.put_line('Procedure 2');
11 end;
12 /
Warning: Procedure created with compilation errors.
Let’s see the error.
SQL> show errors;
Errors for PROCEDURE P1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
7/1 PLS-00103: Encountered the symbol "CREATE"
This is because every programming unit is an independent one, we should use symbol / (slash) in SQL*Plus to compile them separately.
SQL> create or replace procedure p1
2 is
3 begin
4 dbms_output.put_line('Procedure 1');
5 end;
6 /
Procedure created.
SQL> create or replace procedure p2
2 is
3 begin
4 dbms_output.put_line('Procedure 2');
5 end;
6 /
Procedure created.
4. EXECUTE IMMEDIATE
In an anonymous PL/SQL block, we use EXECUTE IMMEDIATE.
SQL> begin
2 execute immediate 'select nvl(first_name, 'NO_VALUE') from employees';
3 end;
4 /
execute immediate 'select nvl(first_name, 'NO_VALUE') from employees';
*
ERROR at line 2:
ORA-06550: line 2, column 46:
PLS-00103: Encountered the symbol "NO_VALUE" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem return
returning <an exponent (**)> <> or != or ~= >= <= <> and or
like like2 like4 likec between into using || multiset bulk
member submultiset
The symbol "* was inserted before "NO_VALUE" to continue.
Solution
For EXECUTE IMMEDIATE statement, you should use extra single quotes to escape original single quotes in the statement like this.
SQL> begin
2 execute immediate 'select nvl(first_name, ''NO_VALUE'') from employees';
3 end;
4 /
PL/SQL procedure successfully completed.
Further reading: How to Use Bind Variable in Oracle
PLS-00103: Encountered the symbol “CREATE” error occurs while running a CREATE block using script, you have not used / (front slash) to let SQLPlus know when the block completes, as a PL/SQL block may contain many instances of ; (semicolon). The CREATE block in the script should be terminated with a front slash (/) to inform Oracle that the code block has been completed.
The error occurs if you try to create two or more PL/SQL objects (procedure, function, package, type, etc.) at the same time. In a single sql session, the PL/SQL objects cannot be created together. You attempt to create several PL/SQL objects at the same time. The error PLS-00103: Encountered the symbol “CREATE” occurs in oracle
The PL/SQL objects such as procedure, functions, package, type etc are container objects that can be used in another objects. A procedure might be called from another procedure. A function can be used within a process. If you try to create two PL/SQL container objects, you’ll get an error PLS-00103: Encountered the symbol “CREATE”.
The two or more ddl, dml, dcl commands can execute in a single session. If two or more PL/SQL objects can not be created in a single command. The oracle sql commands are independent that can not be used in another sql command. The PL/SQL commands can be stored in local variable and can be used for the manipulation.
The Problem
The PL/SQL objects can be used in another PL/SQL objects. For example, the function can be called within the procedure. A procedure can be used within the function. If you try to create PL/SQL objects together, all the object are stored in buffer that can be rolled back. Oracle will not allow to create a PL/SQL object that refers to an another object in the buffer. Oracle forces the object to be persisted.
create type type_student;
create type type_course;
Error
Type TYPE_STUDENT compiled
LINE/COL ERROR
--------- -------------------------------------------------------------
2/1 PLS-00103: Encountered the symbol "CREATE"
Errors: check compiler log
Solution 1
When creating two or more PL/SQL objects, such as a procedure, function, package, or type, the PL/SQL objects should be terminated with a “/.” If Oracle detects a “/” terminator in the PL/SQL code, the objects in the oracle buffer are persisted in the database before going to the next code. Each PL/SQL object will be executed in a separate Oracle buffer, one after the other. PL/SQL objects are saved as soon as they are created.
The ; terminates a SQL query, whereas the / executes whatever is currently in the “buffer.” As a result, when you use a ; and a /, the statement is executed twice.
create type type_student;
/
create type type_course;
Output
Type TYPE_STUDENT compiled
Type TYPE_COURSE compiled
Solution 2
If you try to create a few PL/SQL objects in the PL/SQL code, the PL/SQL objects can be created separately. By executing each PL/SQL object individually, the objects may be created one at a time. Run each command in sequence, ensuring that the objects are created before executing the next PL/SQL code.
Code
create type type_student;
Output
Type TYPE_STUDENT compiled
Code
create type type_course;
Output
Type TYPE_COURSE compiled
I wrote the following Package.
When I compile it I got the following error:
PLS-00103: Encountered the symbol "("
Line 42 Column 66
Which is «PROCEDURE p_fail «
I am helpless. I searched the Internet but found nothing what helps me.
Does anyone has an idea?
Many thanks in advance.
CREATE OR REPLACE PACKAGE BODY boxi_rep.pck_jk_test AS
PROCEDURE p_main
IS
err_num NUMBER;
err_msg VARCHAR2 (200);
BEGIN
boxi_rep.pck_jk_test.p_start;
boxi_rep.pck_jk_test.p_truncate;
EXCEPTION
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := SUBSTR (SQLERRM, 1, 200);
boxi_rep.pck_jk_test.p_fail (err_num, err_msg);
END;
PROCEDURE p_start
IS
BEGIN
/*Make start entry into Log_Jobs*/
DELETE FROM log_jobs
WHERE job_id = '1501'
AND TRUNC (datum) = TRUNC (SYSDATE)
AND end_timestamp IS NULL;
INSERT INTO log_jobs (job_id,
job_name,
datum,
start_timestamp)
VALUES ('1501',
'V$Re_Schedule TEST',
TRUNC (SYSDATE),
SYSDATE);
COMMIT;
END;
PROCEDURE p_fail (in_err_code IN NUMBER, in_err_msg IN VARCHAR2 (200))
IS
BEGIN
UPDATE log_jobs
SET end_timestamp = SYSDATE,
status = 'FAILED - ' || in_err_code || ' - ' || in_err_msg,
duration = TO_CHAR (TO_DATE ('00:00:00', 'hh24:mi:ss') + (SYSDATE - start_timestamp), 'hh24:mi:ss')
WHERE job_id = '1501'
AND end_timestamp IS NULL;
COMMIT;
END;
PROCEDURE p_truncate
IS
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE boxi_rep.jk_test';
END;
END pck_jk_test;
I am getting this error:
[Error] PLS-00103 (23: 9): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
when attempting to run this code. What is it that I’m doing wrong here?
Should I use bulk collect. if so, how?
CREATE OR REPLACE PROCEDURE P_CLEAN_LICENSEE_ARCHIVE AS
BEGIN
/*******************************************************************/
/* This is an array of IDs for licensees */
/*******************************************************************/
array_l := l_arr(1026679, 1026714, 1036991, 1026735, 1026715, 1159363, 1026703, 1169002, 1052762, 1070152, 1026684,
1026685, 1164376, 1026693, 1026733, 1026698, 1026701, 1026680, 1026708, 1026710, 1026688, 1026697,
1026690, 1026691, 1026692, 1099236, 1026694, 1099235, 1026734, 1026700, 1026682, 1026683, 1099142,
1026687, 1026689, 1026732, 1026699, 1047967, 1026702, 1026704, 1026711, 1026712, 1026713, 1026681,
1108357, 1175754, 1079806, 1099275, 1026709, 1099281, 1099282, 1208557, 1175755, 1194482, 1112569);
/*******************************************************************/
/* Loop through the IDs and do the work */
/*******************************************************************/
FOR i IN array_l.FIRST .. array_l.LAST
LOOP
/*******************************************************************/
/* The following SQL retrieves the fkp_fd_rid from all the records */
/* in the archive modified more than one year ago for the passed */
/* CLI_RID, builds a temp table with the fd_rids for use to delete */
/* the records. */
/*******************************************************************/
CREATE TABLE fd_rid AS
SELECT fd.* FROM filedirectory fd
WHERE fd.FD_RID IN (SELECT fkp.fkp_fd_rid FROM filekeypair fkp
WHERE fkp.fkp_keyword = 'CLI_RID'
AND fkp.fkp_value = TO_CHAR(array_l(i)))
AND fd.FD_LASTMODIFIED < SYSDATE-365;
/*******************************************************************/
/* This code then deletes the records from both filekeypair and */
/* filedirectory. */
/*******************************************************************/
DELETE FROM filekeypair WHERE fkp_fd_rid IN (SELECT * FROM fd_rid);
COMMIT;
DELETE FROM filedirectory WHERE fd_rid IN (SELECT * FROM fd_rid);
COMMIT;
/*******************************************************************/
/* Now drop the temp table. */
/*******************************************************************/
DROP TABLE fd_rid;
COMMIT;
END LOOP;
END;