Reputation: 105
I have to use sqldeveloper 4.0. But i cant compile single package in it. It compiles in other programs, but i have to use sqldeveloper. I tryed to compile oracle tutorial package:
CREATE OR REPLACE PACKAGE emp_actions AS -- spec
TYPE EmpRecTyp IS RECORD (emp_id INT, salary REAL);
CURSOR desc_salary RETURN EmpRecTyp;
PROCEDURE hire_employee (
ename VARCHAR2,
job VARCHAR2,
mgr NUMBER,
sal NUMBER,
comm NUMBER,
deptno NUMBER);
PROCEDURE fire_employee (emp_id NUMBER);
END emp_actions;
CREATE OR REPLACE PACKAGE BODY emp_actions AS -- body
CURSOR desc_salary RETURN EmpRecTyp IS
SELECT empno, sal FROM emp ORDER BY sal DESC;
PROCEDURE hire_employee (
ename VARCHAR2,
job VARCHAR2,
mgr NUMBER,
sal NUMBER,
comm NUMBER,
deptno NUMBER) IS
BEGIN
INSERT INTO emp VALUES (empno_seq.NEXTVAL, ename, job,
mgr, SYSDATE, sal, comm, deptno);
END hire_employee;
PROCEDURE fire_employee (emp_id NUMBER) IS
BEGIN
DELETE FROM emp WHERE empno = emp_id;
END fire_employee;
END emp_actions;
And i get Error(14,1): PLS-00103: Encountered the symbol "CREATE" - on create package body line
I tryed to put "/" in front of it but i get Error(13,1): PLS-00103: Encountered the symbol "/".
I dont know the version of the database.
Thank you for help
Upvotes: 0
Views: 2340
Reputation: 191570
If you want to run both statements together then you need to put a /
after each of them, by itself on a new line:
CREATE OR REPLACE PACKAGE emp_actions AS -- spec
...
END emp_actions;
/
CREATE OR REPLACE PACKAGE BODY emp_actions AS -- body
...
END emp_actions;
/
... and then do 'Run Script' (F5, or the button with an icon of a green arrow over a document), rather than 'Run Statement' (Ctrl-Enter, or the button with just a green arrow). The output will go in the 'Script Output' pane.
You can't run multiple statements with 'Run Statement', although you can still select the text of one statement from a script and run that on its own - if it's a query then the output will still appear in the 'Query Result' pane.
If you've created a new package from the 'File->New' menu item, or by right-clicking the 'Package' header in the object browser and selecting 'New Package', then you can only enter the specification in the window that's displayed (the tab has the package name and an icon of a wrapped present). That does actually make more sense - I thought the line number on your second error was wrong, but that matches working in this window.
So enter just the package specification in that window and compile. Then back in the object browser, refresh the package list, right-click your new package name and select 'Create Body'. You'll get a second tab which looks very similar but the tab name will say ' body'. You can put the package body in there and compile it.
Using these views you always have the specification and body in separate tabs. Once both exist each has a button to open the other - the specification window has a button to open the body, and vice versa.
Upvotes: 2