Oracle: DataPatch fails with error PLS-00302

This is how to solve PLS-00302 when executing DataPatch

Oracle: DataPatch fails with error PLS-00302

Sometimes, my job is quite easy. Shutdown standby database, manually patch Oracle home, and restart the standby database ("Standby first").

As the database is not yet in production, I don't have to do a switchover - I just stop the primary database, patch it, and start it again.

Until this point, everything is just fine. I'd execute datapatch, and I'm done.

But every DBA, or even every IT professional, knows that everything can go wrong. No matter how often you did it before.

In my case, I'm patching from 19.3 to 19.26, including some recommended patches, as well as the DataPump Bundle Patch.

But when I executed datapatch -verbose, something felt wrong (sorry, some error messages are in German):

[...]
Validating logfiles...done
Patch 37260974 apply: WITH ERRORS
  logfile: /oracle/cfgtoollogs/sqlpatch/37260974/26040769/37260974_apply_<db name>_2025Apr01_14_32_51.log (errors)
  -> Error at line 32682: script rdbms/admin/prvtbpw.plb
      - 5617/13  PL/SQL: Statement ignored
  -> Error at line 32683: script rdbms/admin/prvtbpw.plb
      - 5618/37  PLS-00302: Komponente 'MCP_L_MD_FLAG_PREINDEX' muss deklariert
  -> Error at line 32686: script rdbms/admin/prvtbpw.plb
      - 5825/5   PL/SQL: Statement ignored
[...]

I searched for that error, and I found Oracle Doc ID 3014764.1. It says:

In certain situations the Post-install or Post-deinstall actions (datapatch -verbose) may fail

Here's the solution:

Therefore the work around is simply to run 'datapatch –verbose' a second time.

Hm, not what I expected, as I faced some errors with datapatch many years ago, where environment variables where wrongly set, or something else.

After executing datapatch -verbose a second time, it workd:

SQL Patching tool version 19.26.0.0.0 Production on Tue Apr  1 14:41:27 2025
Copyright (c) 2012, 2025, Oracle.  All rights reserved.

Log file for this invocation: /oracle/cfgtoollogs/sqlpatch/sqlpatch_1625_2025_04_01_14_41_27/sqlpatch_invocation.log

Connecting to database...OK
Gathering database info...done
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of interim SQL patches:
Interim patch 29213893 (DBMS_STATS FAILING WITH ERROR ORA-01422 WHEN GATHERING STATS FOR USER$ TABLE):
  Binary registry: Installed
  SQL registry: Applied successfully on 01.04.25 14:40:34,159030
Interim patch 34774667 (ORA-7445 IN PURGE QUEUE TABLE):
  Binary registry: Installed
  SQL registry: Applied successfully on 01.04.25 14:40:34,200292
Interim patch 37102264 (OJVM RELEASE UPDATE: 19.26.0.0.250121 (37102264)):
  Binary registry: Installed
  SQL registry: Applied successfully on 01.04.25 14:38:44,220086
Interim patch 37470729 (DATAPUMP BUNDLE PATCH 19.26.0.0.0):
  Binary registry: Installed
  SQL registry: Applied successfully on 01.04.25 14:40:44,281113

Current state of release update SQL patches:
  Binary registry:
    19.26.0.0.0 Release_Update 250118124854: Installed
  SQL registry:
    Applied 19.26.0.0.0 Release_Update 250118124854 successfully on 01.04.25 14:40:32,189700

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  No interim patches need to be rolled back
  No release update patches need to be installed
  No interim patches need to be applied

Albert Einstein said: "Insanity is doing the same thing over and over again and expecting different results." But in this case, I think it's ok 😄