Changing anything object that a package relies upon (e.g.tables, views, triggers, other packages) will automatically mark the package as invalid.We would expect this operation to invalidate the dependent view in releases prior to 11g.CREATE OR REPLACE PACKAGE dep_api AS FUNCTION get_desc (p_id IN dep_tab.id%TYPE) RETURN dep_tab.description%TYPE; PROCEDURE stub; END dep_api; / SELECT object_name, object_type, status FROM user_objects; OBJECT_NAME OBJECT_TYPE STATUS ------------------------------ ------------------- ------- DEP_TAB TABLE VALID DEP_TAB_PK INDEX VALID DEP_API PACKAGE VALID DEP_API PACKAGE BODY INVALID DEPT_TAB_V VIEW VALID 5 rows selected.In previous releases, object dependencies were managed at the object level, so altering an object automatically invalidated all dependent objects.Oracle 11g has more granular dependency management, so only changes that directly affect an object will cause an invalidation.This becomes more likely in 11g with its finer-grained dependencies.
The scenario that created this question: We have a package that is a dependency of another package, sometimes making changes to the "parent" package causes the dependent package to become invalid, but sometimes it doesn't. It would be very useful to simply understand what causes invalidation so I could predict/plan for it.
I will change some of the fields in a query in that package and then recompile it (I don't change or compile any other packages).
I run the script and I get an error that looks like ORA-04068: existing state of packages has been discarded ORA-04061: existing state of package body "USER3.
How can I see which change caused the view to become invalid?
for each of these dependant objects - that should give you an indication of which objects have changed and caused the view to be invalid as a result.