Oracle-DB: How to fix ORA-04062 / find lazy PL/SQL dependencies across DB-links
If you have invalid PL/SQL objects due to later compilation of objects they depend on, then you can recompile them easily using DBMS_UTILITY.compile_schema(schema => USER, compile_all => FALSE); But what happens if your PL/SQL objects like procedures or packages are depending on resources in remote DBs via DB-link? In this case your local objects remain valid, but the DB will check the remote dependencies directly at execution. If the remote object was changed after the last DDL of the local object then the first execution of the local object will fail with ORA-04062. An immediate compilation of the local object is forced than by the DB, so the second and further executions of the local object will work. There are two flavours how the DB handles this lazy compilation, depending on the setting of REMOTE_DEPENDENCIES_MODE: TIMESTAMP - The last DDL timestmp of the local object (User_Objects.Last_DDL_Time) is compared with the last DDL timestamp of the remote object in t...