0

The error I am receiving depends on whether I remove the "/" or leave it.

With /:

PLS-00103: Encountered the symbol /

Without /:

PLS-00103: Encountered the symbol CREATE

What am I doing wrong?

CREATE OR REPLACE PACKAGE EMP_PACKAGE AS 
  TYPE EMP_TYPE IS RECORD 
  ( /* Employee Type */ 
      employee_id       NUMBER(6,0),
      first_name        VARCHAR2(20),
      last_name         VARCHAR2(25),
      email             VARCHAR2(25),
      phone_number      VARCHAR2(20),
      hire_date         DATE,
      job_id            VARCHAR2(10),
      salary            NUMBER(6,2),
      commission_pct    NUMBER(2,2),
      manager_id        NUMBER(6,0),
      department_id     NUMBER(4,0)
  );

  PROCEDURE add_emp(employee_id NUMBER);
  PROCEDURE edit_first_name(employee_id NUMBER, first_name employees.first_name%TYPE);
  FUNCTION get_emp(employee_id NUMBER) RETURN employee_id;
END;    
/
CREATE OR REPLACE PACKAGE BODY EMP_PACKAGE AS
-- procedure will edit an employee's first name
  PROCEDURE edit_first_name(employee_id NUMBER) IS
  BEGIN
    INSERT INTO employees (employees.first_name)
    VALUES (first_name);
  END edit_first_name;
END;
/
  • Which tool do you use to run this script? –  Jul 03 '16 at 20:30
  • Possible duplicate of https://stackoverflow.com/questions/20334067/pls-00103-encountered-the-symbol-create – Ruslan Bes Jul 03 '16 at 20:33
  • I've been using sqldeveloper. Sorry, I tried to use a tag with that in it, but it required that I have 1500 points so it completely skipped my mind to add it in to the post. – Wilson Miller Jul 03 '16 at 20:34

2 Answers2

2

In the package specification you have the line:

FUNCTION get_emp(employee_id NUMBER) RETURN employee_id;

employee_id is not a valid data type.

Once you change that to a valid type then you get to the errors in the package body:

  • You are missing the ADD_EMP procedure and GET_EMP function.
  • PROCEDURE edit_first_name(employee_id NUMBER) does not match the declaration in the package specification as its missing the first_name employees.first_name%TYPE argument.
  • In INSERT INTO employees (employees.first_name) VALUES (first_name); the column is first_name not employees.first_name.
MT0
  • 143,790
  • 11
  • 59
  • 117
  • @MTO I've changed everything that you have mentioned but I'm getting the same error as before. I'm not 100% how to show you the changes I've made due to the character count limit for comments. I do understand all of the suggestions you've made though. – Wilson Miller Jul 03 '16 at 22:12
0

you have some errors in your code. maybe you need something this? i compile this in sql developer without any errors

create or replace PACKAGE EMP_PACKAGE AS 
  TYPE EMP_TYPE IS RECORD 
  ( /* Employee Type */ 
      employee_id       NUMBER(6,0),
      first_name        VARCHAR2(20),
      last_name         VARCHAR2(25),
      email             VARCHAR2(25),
      phone_number      VARCHAR2(20),
      hire_date         DATE,
      job_id            VARCHAR2(10),
      salary            NUMBER(6,2),
      commission_pct    NUMBER(2,2),
      manager_id        NUMBER(6,0),
      department_id     NUMBER(4,0)
  );

  PROCEDURE add_emp(p_employee_id NUMBER);
  PROCEDURE edit_first_name(p_employee_id NUMBER, p_first_name employees.first_name%TYPE);
  FUNCTION get_emp(p_employee_id NUMBER) RETURN EMP_TYPE;
END;    

/

create or replace PACKAGE BODY EMP_PACKAGE AS

-- procedure will edit an employee's first name
  PROCEDURE edit_first_name(p_employee_id NUMBER, p_first_name employees.first_name%TYPE) IS
  BEGIN
    update employees emp
       set emp.first_name = p_first_name
     where emp.employee_id = p_employee_id;

  END edit_first_name;

  PROCEDURE add_emp(p_employee_id NUMBER) IS BEGIN
    null;
  END;

  FUNCTION get_emp(p_employee_id NUMBER) RETURN EMP_TYPE IS
  BEGIN
    return null;
  END;

END;
  • I think there might be something wrong with the database that my connection is based on as I copied in your code exactly as is just to test this and I'm still receiving the same error. Here is a screengrab of what was displayed to me. http://imgur.com/pLTQyZ3 – Wilson Miller Jul 05 '16 at 14:24
  • copy it not in package. create new "sql file" file->new-> All items -> Sql File and copy there. and after run – Анатолий Предеин Jul 05 '16 at 16:11