Keeping your Oracle database up to date with patches is crucial for both security and performance. However, patching issues can arise, leading to errors such as ORA-20001. In this blog, we’ll walk through a real-world troubleshooting scenario where an Oracle 19c database reported an outdated patch level, and the datapatch process was required to resolve inconsistencies.
Oracle Datapatch ORA-20001 Issue Description
The database was reporting the following patch level: Database Jan 2022 Release Update: 19.20.0.0.220118 (35524739)
A review of the logs indicated that the latest patch might not have been fully applied, as shown by the following error:
2022-04-20T10:35:27.059454-04:00
Unable to obtain current patch information due to error: 20001, ORA-20001: Latest XML inventory is not loaded into the table
ORA-06512: at “SYS.DBMS_QOPATCH”, line 777
ORA-06512: at “SYS.DBMS_QOPATCH”, line 864
ORA-06512: at “SYS.DBMS_QOPATCH”, line 2222
ORA-06512: at “SYS.DBMS_QOPATCH”, line 740
ORA-06512: at “SYS.DBMS_QOPATCH”, line 2247
This error suggested that the April patch might have been applied to the binaries, but the datapatch was either skipped or failed during execution.
Fixing the Issue
The following steps were taken to resolve the issue and successfully apply the patch:
Step 1: Backup the qopiprep.bat File
Before making any changes, a backup of the relevant script was taken:
#cd $ORACLE_HOME/QOpatch
#cp qopiprep.bat qopiprep.bat_bkp
Step 2: Modify the Script
The script .bat was modified to ensure the correct shell interpreter was used:
#!/bin/sh # Original line
was changed to:
#!/usr/bin/ksh # Updated line
Step 3: Run Datapatch
The datapatch utility was then executed to apply any missing patches:
cd $ORACLE_HOME/OPatch
./datapatch -verbose
Expected Output:
SQL Patching tool version 19.20.0.0 Production on Mon Sep 19 22:33:20 2022
…
Current state of SQL patches:
Bundle series DBRU:
ID 220118 in the binary registry and ID 220118 in the SQL registry
Installation queue:
Output: Nothing to roll back
Output: Nothing to apply
SQL Patching tool complete
Verification:
To confirm that the patching was successful, SQL*Plus was used to verify the queryable inventory:
sqlplus / as sysdba
SQL> select dbms_sqlpatch.verify_queryable_inventory from dual;
Expected Output:
VERIFY_QUERYABLE_INVENTORY
—————————-
OK
Conclusion
This case study highlights the importance of verifying patch applications and running datapatch after installing updates—especially when addressing Oracle datapatch ORA-20001 errors—to ensure your Oracle database remains fully patched and operational.
Do you have more Oracle questions or need expert tips? Explore our Oracle blogs for in-depth guides, updates, and expert solutions.