45

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?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Surya
  • 451
  • 1
  • 5
  • 6
  • 9
    You are missing a `/` after the `create` for the package definition. –  Dec 02 '13 at 17:19
  • 3
    Yes after adding a '/' on a new line as the first character after the definition solved the problem. Thank you – Surya Dec 02 '13 at 18:04
  • And BTW, the code is to be executed as a script and only then will it be successful. – Surya Dec 02 '13 at 18:04

4 Answers4

74

At line 5 there is a / missing.

There is a good answer on the differences between ; and / here.

Basically, when running a CREATE block via script, you need to use / to let SQLPlus know when the block ends, since a PL/SQL block can contain many instances of ;.

Community
  • 1
  • 1
Drumbeg
  • 1,914
  • 1
  • 15
  • 22
  • 1
    People coming here because of `PLS-00103` after creating a package with **Liquibase**: if you are using `` to do it, you have to put the package definition in one `` block, and the actual package body in another `` block after that. – walen May 10 '21 at 14:27
1

For me / had to be in a new line.

For example

create type emp_t;/

didn't work

but

create type emp_t;

/

worked.

Upulie Han
  • 431
  • 1
  • 7
  • 15
0

In my case EXECUTE IMMEDIATE ('CREATE TABLE ...') works, for example:

DECLARE 
   myVar INT;
BEGIN
SELECT 2 INTO myVar FROM dual;
IF myVar > 1 THEN
    EXECUTE IMMEDIATE('Create Global Temporary Table TestTemp ( id VARCHAR2(2) ) ON COMMIT PRESERVE ROWS');
END IF;
END;

Reference to Create Table As within PL/SQL?

yu yang Jian
  • 6,680
  • 7
  • 55
  • 80
-3

Run package declaration and body separately.

Nikhil
  • 1
  • 4
    Explaining a little bit more would be appreciated by the OP, I think. – β.εηοιτ.βε Apr 22 '15 at 23:56
  • This would work around the issue, without really explaining the problem with the original code sample. Some teams will separate spec and body into separate files as a matter of course. – Drumbeg Mar 08 '18 at 10:32