Error
Error Code:
ORA-04062
Oracle Error ORA-04062: Timestamp Mismatch
Description
The ORA-04062 error in Oracle Database indicates a mismatch between the timestamp or signature of a stored procedure being called and the timestamp/signature expected by the RPC stub. This typically occurs after the stored procedure has been recompiled or modified without the caller being updated.
Error Message
string of string has been changed
Known Causes
3 known causesProcedure Recompilation
The target stored procedure has been recompiled or modified since the caller was compiled, resulting in a timestamp/signature mismatch. ⚙
Incorrect RPC Stub
The RPC stub used to call the stored procedure is outdated and doesn't reflect the current version of the procedure. 💻
Database Upgrade
A database upgrade or patch application has changed the internal representation of the stored procedure. 🌐
Solutions
3 solutions available1. Recompile Invalid Objects easy
The most common cause is a change in a dependent object, requiring recompilation of the affected PL/SQL objects.
1
Connect to the Oracle database as a user with DBA privileges or the owner of the affected objects.
2
Identify invalid objects. The error message usually indicates the object that has changed. You can also query DBA_OBJECTS or USER_OBJECTS for invalid objects.
SELECT owner, object_name, object_type, status FROM dba_objects WHERE status = 'INVALID';
-- Or as a specific user:
SELECT object_name, object_type, status FROM user_objects WHERE status = 'INVALID';
3
Recompile the invalid objects. If the error message directly points to a PL/SQL object (e.g., a procedure, function, package, or trigger), recompile that specific object. Otherwise, recompile all invalid objects.
-- Recompile a specific object:
ALTER PACKAGE package_name COMPILE;
ALTER PROCEDURE procedure_name COMPILE;
ALTER FUNCTION function_name COMPILE;
ALTER TRIGGER trigger_name COMPILE;
-- Recompile all invalid objects in the schema:
EXEC UTL_RECOMP.RECOMP_PARALLEL(degree => 10); -- Adjust degree based on your system resources
4
Retry the operation that previously failed with ORA-04062.
2. Identify and Recreate the Dependent Object medium
If recompiling doesn't resolve the issue, a more fundamental change to a dependent object might be the cause. This requires identifying and recreating the problematic object.
1
Examine the exact error message. The 'string of string' part often reveals the name of the object that has changed and is causing the timestamp mismatch.
2
Query the data dictionary to find dependencies. Find out which objects depend on the object that has changed.
SELECT * FROM DBA_DEPENDENCIES WHERE REFERENCED_OWNER = 'SCHEMA_OWNER' AND REFERENCED_NAME = 'CHANGED_OBJECT_NAME';
-- Replace SCHEMA_OWNER and CHANGED_OBJECT_NAME with actual values.
3
Recreate the dependent object(s). If the changed object is a table, view, or another PL/SQL unit, the dependent object might need to be recreated.
-- Example: If a table was altered, and a view depends on it:
DROP VIEW view_name;
CREATE OR REPLACE VIEW view_name AS ...; -- Recreate the view with the correct definition
4
After recreating the dependent object, recompile any invalid PL/SQL units if they become invalid.
ALTER PACKAGE package_name COMPILE;
ALTER PROCEDURE procedure_name COMPILE;
5
Retry the operation.
3. Flush the Shared Pool (Caution Advised) advanced
In rare cases, outdated cached information in the shared pool can lead to this error. Flushing the shared pool can resolve it but impacts all active sessions.
1
Connect to the Oracle database as a SYSDBA user.
2
Flush the shared pool. This action invalidates all cursors and cached data in the shared pool, forcing Oracle to reparse and rebind objects on the next access.
ALTER SYSTEM FLUSH SHARED_POOL;
-- For RAC environments, you might need to run this on all nodes or use DBMS_SHARED_POOL.FLUSH.
3
Immediately after flushing, recompile any invalid objects to ensure they are in a consistent state.
EXEC UTL_RECOMP.RECOMP_PARALLEL(degree => 10);
4
Retry the operation. Be aware that flushing the shared pool can cause a temporary performance degradation as objects are reloaded and reparsed.