Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

REUSE SETTINGS supresses error messages when compiling an invalid object

MarwimJan 27 2009 — edited Jan 27 2009
Hello,

my test:
Create a table and a packaged procedure referencing the table. Then drop the table and recompile the package:
CREATE TABLE x (
    y     NUMBER
    );

CREATE OR REPLACE PACKAGE y
AS
PROCEDURE z;
END y;
/
SHOW ERRORS

CREATE OR REPLACE PACKAGE BODY y
AS

PROCEDURE z
IS
  v_count PLS_INTEGER;
BEGIN
  SELECT COUNT(*)
  INTO v_count
  FROM x;
END z;
END y;
/
SHOW ERRORS

DROP TABLE x;
PROMPT 1.Compile package
ALTER PACKAGE y COMPILE;

SHOW ERRORS

PROMPT 2.Compile package body
ALTER PACKAGE y COMPILE BODY;

SHOW ERRORS

PROMPT 3.Compile package with "REUSE SETTINGS"
ALTER PACKAGE y COMPILE REUSE SETTINGS;

SHOW ERRORS

PROMPT 4.Compile package body with "REUSE SETTINGS"
ALTER PACKAGE y COMPILE BODY REUSE SETTINGS;

SHOW ERRORS

SELECT object_name
      ,object_type
FROM   user_objects
WHERE  status = 'INVALID';
--DROP PACKAGE y;
Partly unexpected output
Tabelle wurde erstellt.


Package wurde erstellt.

Keine Fehler.

Package Body wurde erstellt.

Keine Fehler.

Tabelle wurde gelöscht.

1.Compile package

Warnung: Paket wurde mit Kompilierungsfehlern geõndert.

Keine Fehler.
2.Compile package body

Warnung: Paketrumpf wurde mit Kompilierungsfehlern geõndert.

Fehler bei PACKAGE BODY Y:

LINE/COL ERROR
-------- -----------------------------------------------------------------
8/3      PL/SQL: SQL Statement ignored
10/8     PL/SQL: ORA-04044: procedure, function, package, or type is not
         allowed here

3.Compile package with "REUSE SETTINGS"

Warnung: Paket wurde mit Kompilierungsfehlern geõndert.

Keine Fehler.
4.Compile package body with "REUSE SETTINGS"

Warnung: Paketrumpf wurde mit Kompilierungsfehlern geõndert.

Keine Fehler.

OBJECT_NAME     OBJECT_TYPE
--------------- -------------------
Y               PACKAGE BODY

1 Zeile wurde ausgewõhlt.
It says
- Table created
- Package created
- Package body created
- Table dropped
- Package header compiled with errors (why?)
- Package body compiled with errors (shown error is expected)
- Package header compiled with errors (again why?)
- Package body compiled with errors (no errors shown)

So why is the header compiled with errors, when the object is valid.
And why is no error shown for COMPILE REUSE SETTINGS when there are errors for the body?

I use REUSE SETTINGS when recompiling invalid objects that were compiled for debug with
ALTER PACKAGE abc COMPILE PLSQL_DEBUG = TRUE REUSE SETTINGS
Regards
Marcus

Version:
SQL*Plus: Release 10.2.0.1.0 - Production on Di Jan 27 12:45:20 2009

Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2009
Added on Jan 27 2009
5 comments
2,133 views