While running datapatch tool in Oracle 12c, as part of post patching got ORA-20013 error.

Use below steps to solve the issue.

Problem:



cd /oracle/app/oracle/product/12.1.0.2/dbhome_1/OPatch

./datapatch -verbose
SQL Patching tool version 12.2.0.0.0 on Thu Feb 25 11:02:17 2016
Copyright (c) 2014, Oracle.  All rights reserved.

Connecting to database...OK
catcon: ALL catcon-related output will be written to /tmp/sqlpatch_catcon__catcon_3220.lst
catcon: See /tmp/sqlpatch_catcon_*.log files for output generated by scripts
catcon: See /tmp/sqlpatch_catcon__*.lst files for spool files, if any
Bootstrapping registry and package to current versions...done

Queryable inventory could not determine the current opatch status.
Execute 'select dbms_sqlpatch.verify_queryable_inventory from dual'
for the complete error.
Prereq check failed, exiting without installing any patches.

Please refer to MOS Note 1609718.1 for information on how to resolve the above errors.

SQL Patching tool complete on Thu Feb 25 11:02:23 2016


SQL> select dbms_sqlpatch.verify_queryable_inventory from dual;

VERIFY_QUERYABLE_INVENTORY
--------------------------------------------------------------------------------
ORA-20013: DBMS_QOPATCH ran mostly in non install area

 

Solution:

Check the patching related directories from dba_directories.

 

SQL> select DIRECTORY_NAME, DIRECTORY_PATH from dba_directories where DIRECTORY_NAME like '%OPATCH%';
  2

DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
OPATCH_INST_DIR
/u01/app/oracle/product/12.0.4/dbhome/OPatch

OPATCH_SCRIPT_DIR
/u01/app/oracle/product/12.0.4/dbhome/QOpatch

OPATCH_LOG_DIR
/u01/app/oracle/product/12.0.4/dbhome/QOpatch


 

Check the ORACLE_HOME :

echo $ORACLE_HOME
/oracle/app/oracle/product/12.1.0.2/dbhome_1

We can see that directories are pointing to wrong location.
So recreate them pointing to correct ORACLE_HOME location.

 

SQL> create or replace  directory  OPATCH_INST_DIR as '/oracle/app/oracle/product/12.1.0.2/dbhome_1/OPatch';

Directory created.



SQL>  create or replacce  directory OPATCH_SCRIPT_DIR  as  '/oracle/app/oracle/product/12.1.0.2/dbhome_1/QOpatch';

Directory created.

SQL> create or replace  directory OPATCH_LOG_DIR as  '/oracle/app/oracle/product/12.1.0.2/dbhome_1/QOpatch';

Directory created.


Now run the datapatch tool, it should work fine.