Kaushal Talniya
Kaushal Talniya

Reputation: 192

Error while compiling the package in PL/SQL. Error(7,1): PLS-00103: Encountered the symbol "CREATE"

Error(7,1): PLS-00103: Encountered the symbol "CREATE". I tried to put / before create but then error was Error(6,1): PLS-00103: Encountered the symbol "/" .

I am new to PL/SQL programming, could you please help on this.

CREATE OR REPLACE PACKAGE EMP_BULK_INSERT AS 

     PROCEDURE Bulk_Insert;

    END EMP_BULK_INSERT;
    /* package body */
    CREATE OR REPLACE PACKAGE BODY EMP_BULK_INSERT AS

      PROCEDURE Bulk_Insert
      AS
         /* select all records from source table */
          CURSOR kt_test_cur IS
            SELECT empid
            ,      empband
            ,      empname
            ,      workexp
            ,      salary
            from   kt_test;

            /* create nested table type and variable that will hold BIG_TABLE's records */
            TYPE kt_test_ntt IS TABLE OF kt_test_cur%ROWTYPE;
            l_kt_test kt_test_ntt;
       BEGIN
            /* open pointer to SELECT statement */
            OPEN kt_test_cur;
            /* collect data in the collection */
            FETCH kt_test_cur BULK COLLECT INTO l_kt_test;
            /* close the pointer */
            CLOSE kt_test_cur;

           /* print size of the collection */
           DBMS_OUTPUT.PUT_LINE('Nested table holds: ' || TO_CHAR(l_kt_test.COUNT) || ' records.');

            /* write data down to target table */
            FORALL indx IN l_kt_test.FIRST..l_kt_test.LAST
                INSERT INTO kt1_test(empid,empband,empname,workexp,salary)
                VALUES (l_kt_test(indx).empid,l_kt_test(indx).empband,l_kt_test(indx).empname,l_kt_test(indx).workexp,l_kt_test(indx).salary);

             DBMS_OUTPUT.PUT_LINE('Number of rows inserted ' || SQL%ROWCOUNT || ' rows');

             COMMIT;

        END Bulk_Insert;

    END EMP_BULK_INSERT;

Upvotes: 0

Views: 438

Answers (2)

Hauke
Hauke

Reputation: 242

If you want to manipulate the package vie the dedicated object viewa of SQL Developer you have to separate package def and body and use the "/" in neither:

First compile the package spec (without "/"). Then open the body in a separate tab page with the small package icon (left from the compile icon). Edit your body code and compile there (again, without the "/").

Upvotes: 0

Hauke
Hauke

Reputation: 242

The "/" needs to be on a blank line, all by itself. Like this:

CREATE OR REPLACE PACKAGE abc AS
...
END;
/
CREATE OR REPLACE PACKAGE BODY abc AS
...
END;
/

The meaning of the "/" is to execute the command buffer. In this case it executes the previous PL/SQL block.

For a more in depth discussion on this topic, see here on stack overflow

Upvotes: 1

Related Questions