Oracle flags schema objects as incorrect—usually reported as INVALID—when it cannot resolve their dependencies or when compilation fails. The fix is not to force everything valid with a single script; it’s to identify which objects are actually broken, correct the underlying cause, and recompile in dependency order. The key condition: an object can be INVALID and still work fine if it has never been executed, but an object that is both INVALID and fails on use is genuinely broken. This guide treats Oracle Database 19c as the reference release (the long-term support version most estates run in 2026), and the same mechanics apply broadly across 12c through 23ai.

What “Incorrect Objects” Means in Oracle

Oracle stores compiled code in two related forms: source text in the data dictionary and compiled bytecode in the library cache plus persisted metadata. When you create or alter a PL/SQL unit, a view, a synonym target, or a type, the compiler resolves every reference. If it can’t, the object is marked INVALID with a compile error recorded in USER_ERRORS (or ALL_ERRORS/DBA_ERRORS).

Two distinct problems hide behind the phrase “incorrect objects.” The first is a genuine compile failure: bad SQL, a missing table, a privilege gap, a datatype mismatch. The second is a cascade: a base object changes, and every dependent object flips to INVALID automatically. Oracle’s dependency model tracks these links, which is why altering a table column can invalidate dozens of views and procedures you never touched. A third, less common case is a metadata inconsistency where the object is valid but produces wrong results—that’s a data or logic bug, not an invalid-object problem, and recompiling won’t help.

The practical consequence: you should never blanket-recompile a production schema just to clear the INVALID count. Fix causes first, then compile. Oracle’s own documentation warns that automatic recompilation happens on first use, so many invalid objects are self-healing when exercised—but that healing fails if the root cause persists.

Prerequisites and Safety Checks Before You Touch Anything

Before running a single ALTER … COMPILE, establish scope and a rollback path.

1: Confirm you can connect with a privileged account. Compiling objects owned by another schema requires ALTER ANY PROCEDURE (for PL/SQL) or ALTER ANY TABLE (for views), typically via a DBA role. 2: Capture the current state. Query the count of invalid objects by owner and type, and export the list to a file so you can compare before and after. 3: Know your window. Recompiling large packages consumes CPU and library cache; avoid peak hours on busy systems. 4: Have a rollback plan. Fixes to source code should be scripted from version control, not typed ad hoc. If you don’t have the original DDL, extract it first with DBMS_METADATA.GET_DDL.

A query that gives you the inventory:

SELECT owner, object_type, COUNT(*)
FROM dba_objects
WHERE status = 'INVALID'
GROUP BY owner, object_type
ORDER BY 3 DESC;

Run the same against USER_OBJECTS if you only care about your own schema. Record the output. That baseline is your success check later.

Step 1: Find the Genuinely Broken Objects, Not the Cascades

The INVALID flag is blunt. A view that depends on another invalid view shows INVALID too, even though its own SQL is perfect. Recompiling it first wastes effort because it will fail again until the base is fixed.

Start at the leaves of the dependency tree. The DBA_DEPENDENCIES view maps who references whom:

SELECT name, type, referenced_owner, referenced_name, referenced_type
FROM dba_dependencies
WHERE owner = 'APP'
ORDER BY referenced_type, referenced_name;

Objects that reference nothing invalid—or reference only tables—are your likely roots. Cross-reference against the invalid list and compile those first.

For each candidate, read the actual error. This is the single most important step, and it’s the one people skip:

SELECT name, type, line, position, text
FROM dba_errors
WHERE owner = 'APP'
ORDER BY name, sequence;

The error text tells you the fix. ORA-00942 means a missing table or privilege. ORA-04063 means a dependent object is invalid. PLS-00201 means an identifier isn’t declared. ORA-06550 with a line number points at the exact statement. Success at this step means you can name the cause for every root invalid object, not just count them.

Step 2: Recompile the Roots in Dependency Order

Once you know which objects are roots, compile them individually rather than in bulk. Individual compilation surfaces errors immediately and stops the cascade cleanly.

For a package:

ALTER PACKAGE app.order_pkg COMPILE;

For a package body alone (when the spec is unchanged):

ALTER PACKAGE app.order_pkg COMPILE BODY;

For a view:

ALTER VIEW app.active_orders COMPILE;

For a procedure, function, trigger, or type, the syntax mirrors the object type. Then re-query DBA_ERRORS for that object to confirm zero rows. A successful compile clears INVALID for that object and begins resolving dependents.

The sequencing rule: compile base objects before dependents. If a view depends on a function, compile the function first. If a package body calls another package’s public procedure, compile the callee’s spec first. You can verify order with DBA_DEPENDENCIES by walking referenced_name upward.

After the roots are clean, handle the cascade. Oracle will often recompile dependents automatically the next time they’re referenced, but you can force it deterministically. The built-in utility does this in dependency-aware order:

BEGIN
  UTL_RECOMP.RECOMP_SERIAL('APP');
END;
/

Or, for parallel recompilation on a large schema:

BEGIN
  UTL_RECOMP.RECOMP_PARALLEL(4, 'APP');
END;
/

UTL_RECOMP is the sanctioned tool precisely because it respects dependencies. Running it before fixing root causes, however, just reproduces the same errors faster. Order matters.

The success check: re-run the inventory query from the prerequisites. For a healthy schema, INVALID should drop to zero—or to a small set of objects you’ve documented as intentionally unused. If the count doesn’t move, the cause is still present, and you return to Step 1.

Step 3: Fix the Underlying Cause, Not the Symptom

Recompiling is the easy part. The real work is the cause behind each root error. Here are the common categories and what they actually demand.

Missing object or wrong schema. ORA-00942 usually means the referenced table doesn’t exist in the expected schema, or the compiling user lacks a direct grant. In Oracle, privileges acquired through roles are not available inside definer’s-rights PL/SQL at compile time—a classic trap. Grant the privilege directly to the owner, or use invoker’s rights where appropriate. Don’t “fix” it by granting DBA.

Privilege drift. Someone revoked SELECT on a table, or a role changed. The error is ORA-01031 or ORA-00942 depending on context. Re-grant the minimum privilege the object needs, not a broad role.

Datatype or signature mismatch. A procedure call passes a NUMBER where the signature expects VARCHAR2, or a package spec changed and the body wasn’t recompiled. The error is PLS-00306 or PLS-00323. Align the call or recompile the body against the current spec.

Dependency on a changed object. A view references a column that was dropped. ORA-00904 points at the identifier. The fix is to alter the view’s definition, not to re-add a column you deliberately removed.

Remote or database-link dependencies. Objects referencing a remote table via a database link fail when the link is down or the remote object changed. Test the link with a simple SELECT and confirm the remote object’s status before blaming local code.

Editioning and invalid synonyms. In edition-based redefinition environments, a synonym may point to a non-existent editioned object. Check ALL_SYNONYMS and confirm the target resolves in the current edition.

Each category has a different fix, and none of them is “recompile again.” If your DBA_ERRORS read points at a missing privilege, granting it is the fix; if it points at dropped column, editing source is the fix. State the cause for each object before you declare victory.

Step 4: Handle the Tricky Cases—Views, Synonyms, Types, and Java

PL/SQL packages are the common case, but several object types need special handling.

Views that depend on invalid views. A view can be INVALID because its base view is INVALID. Compile bottom-up. If a view uses SELECT *, changing the base table’s columns silently changes the view’s shape—recompiling may not catch a semantic problem. Check the column list explicitly.

Synonyms. A synonym itself never truly “compiles,” but it becomes unusable if its target is invalid or dropped. Recompile or recreate the target first; the synonym then resolves. Confirm with SELECT * FROM the synonym in a test session.

Object types and type bodies. Types have specs and bodies like packages and must be compiled spec-first. A type used in a table column that’s changed can ripple into dependent tables and indexes—treat these changes as schema migrations, not quick fixes.

Java sources and classes. Oracle’s internal JVM stores Java objects with their own resolver. Errors surface as ORA-29532 or ORA-29541. Fix the Java source, then use ALTER JAVA SOURCE … COMPILE or reload the class, and resolve classpath issues through the database’s Java options. These are rare in modern estates but painful when they appear.

Scheduler jobs and materialized views. A broken job or materialized view refresh may be the visible symptom, with an invalid procedure as the root. Check DBA_SCHEDULER_JOBS and DBA_MVIEWS state alongside the invalid-object list.

A Worked Example: Tracing One Cascade

Suppose the APP schema shows 47 invalid objects after a deployment: 30 views, 12 procedures, 4 packages, and 1 function. The instinct is to run UTL_RECOMP and move on. Instead:

Read DBA_ERRORS for a sample procedure. It reports PLS-00201: identifier ‘ORDERS_V2’ must be declared. That tells you the procedure references a view that doesn’t exist—likely renamed during deployment.

Check DBA_DEPENDENCIES. The procedure depends on a view named ORDERS_V2, which itself is invalid with ORA-00904 on a column.

Trace further: ORDERS_V2 selects from ORDERS, whose column CUSTOMER_REF was renamed to CUST_REF in the release. That’s the root.

The fix is to update ORDERS_V2’s definition to use CUST_REF, compile it, then compile the 12 procedures and 4 packages that reference it. The 30 views compile as their dependencies clear. The function likely references a package that’s now fixed.

Outcome: 47 invalid objects resolved by one source correction plus ordered compiles. Had you run UTL_RECOMP first, you’d have generated 47 identical errors and learned nothing.

Preventing Recurrence

The invalid-object problem is usually a process gap, not a database defect. Three practices cut it dramatically.

Compile in the deployment pipeline. After any DDL migration, run UTL_RECOMP on affected schemas as a pipeline step and fail the build if INVALID count exceeds your baseline. Catching it in staging is cheaper than in production.

Track dependencies before changes. Before renaming or dropping a column, query DBA_DEPENDENCIES for everything referencing it. A five-minute check prevents a cascade. Many teams wrap this in a pre-migration script that lists dependents.

Avoid SELECT * in views and procedures. Explicit column lists mean a base-table change breaks loudly at the point of definition, not silently in a downstream object. This is the single highest-leverage code standard for reducing invalid-object incidents.

Monitor at low frequency. A daily job that counts invalid objects by owner and alerts on change catches drift before users do. Keep the baseline documented so intentional invalids—objects in a disabled feature schema, say—don’t trigger noise.

When to Stop and Escalate

Some symptoms mean the problem is beyond application code. If recompilation fails with ORA-00600 or ORA-07445 (internal errors), stop and engage Oracle Support with the trace files—these are kernel bugs, not SQL fixes. If invalid objects reappear within minutes of being cleared, something is actively dropping or altering dependencies, which points to a competing deployment or a scheduled job. If the data dictionary itself reports inconsistent state—for example, DBA_OBJECTS disagrees with DBA_ERRORS—run the appropriate dictionary health checks and involve a DBA before making changes. And if a fix requires altering a shared base table in production, treat it as a change-controlled migration, not a hotfix.

FAQ

Can I just run UTL_RECOMP and be done? Only if the root causes are already fixed. Running it against a schema with unresolved errors reproduces the same failures in dependency order. It’s a cleanup tool, not a diagnostic one.

Why do objects go INVALID when I didn’t change them? Because something they depend on changed. Oracle invalidates dependents automatically when a referenced object is altered or dropped. The dependency chain, not your editing, is the trigger.

Is an INVALID object always broken? No. Oracle recompiles on first use, so many invalid objects heal themselves when executed. An object that stays INVALID after being used is genuinely broken. Check by executing it, then re-reading its status and errors.

Does this differ on 23ai? The mechanics—DBA_ERRORS, DBA_DEPENDENCIES, UTL_RECOMP, ordered compilation—carry forward. Release-specific compiler strictness and new editioning behavior can change which errors appear, so verify against your exact version’s documentation before scripting a bulk fix.