Manage Learn to apply best practices and optimize your operations.

How to avoid invalid objects in Oracle and modify during off hours

Oracle expert Brian Peasland explains how to avoid invalid objects in Oracle and if it is possible to modify objects such as packages and views during working hours.

I work for a company that requires 24/7 access to the database, but when scheduled application code is modified, objects are invalidated such as packages, package body and views. We are forced to apply these types of modification (application) packages during off hours, when the online community is at a minimum.

The question is, how can we implement application code changes during normal working hours and avoid the outage caused by objects becoming invalidated?

In most cases, you cannot perform these tasks during normal working hours without invaliding objects. Think about it this way, you modify stored procedure PROC1, which is called by database trigger TRIG1. How is TRIG1 to know that the changes you made to PROC1 are syntactically correct? TRIG1 does not know this so the object becomes INVALID. The next time a user calls TRIG1, Oracle will recompile it to ensure PROC1 has not broken TRIG1. If everything is still good, Oracle executes TRIG1 for the user. If the changes to PROC1 broke TRIG1, then the user will receive an error. But Oracle will not know for sure until it recompiles the INVALID object.

Depending on what changes you are attempting, the DBMS_REDEFINITION package can help you perform these changes with minimal downtime. But you may still run into situations where there is an impact on end users or online visitors.

Dig Deeper on Oracle database design and architecture