quote:
----------------------------------------------------------------------
Accidentaly I created a spec named body.
Does anybody know how to get rid of it?
DROP PACKAGE BODY; does not work!
----------------------------------------------------------------------
Olaf,
What I don't understand is how you created a package with the name of body in the first place.
It's pretty hard to do, even when you try, as you'll soon see.
What do you get when you run the following query, Olaf? (Note, you'll need to substitute your own schema for SCOTT):
SQL> SELECT object_name
2 FROM all_objects
3 WHERE owner = 'SCOTT'
4 AND object_type = 'PACKAGE'
5 AND UPPER(object_name) LIKE '%BODY%'
6 /
no rows selected
This tells me that we're staring out "fresh".
Now, I'm going to try to create a package spec with the name body:SQL> CREATE OR REPLACE PACKAGE body AS
2 FUNCTION f1 RETURN NUMBER;
3 END body;
4 /
CREATE OR REPLACE PACKAGE body AS
*
ERROR at line 1:
ORA-04050: invalid or missing procedure, function, or package name Notice, it doesn't let me create a package named body, because body is a reserved word that ordinarily comes right after the text CREATE OR REPLACE PACKAGE.
Since PL/SQL wouldn't let me create a package with the name body outright, this time, I'm going to try creating a package with the name of body by surrounding the word body with quotes, and it works:SQL> CREATE OR REPLACE PACKAGE "body" AS
2 FUNCTION f1 RETURN NUMBER;
3 END "body";
4 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY "body" AS
2 FUNCTION f1 RETURN NUMBER
3 IS
4 BEGIN
5 RETURN (TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDD')));
6 END f1;
7 END "body";
8 /
Package body created.
Here we see, when I query all_objects, the package with the name body exists, and apparently without quotes:SQL> SELECT object_name
2 FROM all_objects
3 WHERE owner = 'SCOTT'
4 AND object_type = 'PACKAGE'
5 AND UPPER(object_name) LIKE '%BODY%'
6 /
OBJECT_NAME
------------------------------
body
But when I try to invoke my package's function, it doesn't work (I'm not sure why....?):SQL> SELECT body.f1 FROM DUAL;
SELECT body.f1 FROM DUAL
*
ERROR at line 1:
ORA-00904: invalid column name When I surround my package body's name with quotes, however, the above call works:SQL> SELECT "body".f1 FROM DUAL;
F1
----------
20030306 So that proves that the package really exists. Now I try to drop the package, like you're trying to do, Olaf:SQL> DROP PACKAGE body;
DROP PACKAGE body
*
ERROR at line 1:
ORA-04050: invalid or missing procedure, function, or package name Since that doesn't work, I surround body with quotes:SQL> <font color=red>DROP PACKAGE "body";</font>
Package dropped.
And just to make sure the package is really gone, I once again query all_objects:SQL> SELECT object_name
2 FROM all_objects
3 WHERE owner = 'SCOTT'
4 AND object_type = 'PACKAGE'
5 AND UPPER(object_name) LIKE '%BODY%'
6 /
no rows selected
SQL>
....and it's gone.
I hope this helps, Olaf.
Art