How to Check PDB is compatible with a new CDB

To test if a PDB is compatible with a new CDB before plugging it in, use the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function in the target CDB. This function checks for incompatibilities like patch levels, character sets, database options, and the COMPATIBLE parameter setting.

Generate a PDB Description File (XML): Before you can run the check, you must have an XML metadata file that describes the PDB. This is usually created during the unplugging process from the source CDB or by using DBMS_PDB.DESCRIBE.
Access to Target CDB: You need SYSDBA privileges on the target CDB.

— On Source CDB

BEGIN
DBMS_PDB.DESCRIBE(
pdb_descr_file => '/tmp/pdb_description.xml',
pdb_name => 'YOUR_PDB_NAME');
END;
/
 $ grep -v "<parameter>" /tmp/pdb_description.xml > /tmp/pdb_description.xml_no_param.xml 

— On Target CDB

SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/tmp/pdb_description.xml',
pdb_name => 'NEW_PDB_NAME')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE('Is the future PDB compatible? ==> ' || compatible);
END;
/

Check for Violations

COLUMN MESSAGE FORMAT A60
COLUMN STATUS FORMAT A10
SELECT NAME, TYPE, MESSAGE, STATUS FROM PDB_PLUG_IN_VIOLATIONS
ORDER BY TIME;

PL/SQL package SYS.DBMS_BACKUP_RESTORE version PL/SQL package SYS.DBMS_RCVMAN version in TARGET database is not current

Try to connect to RMAN catalog with the following errors:

PL/SQL package SYS.DBMS_BACKUP_RESTORE version 19.20.00.00 in TARGET database is not current
PL/SQL package SYS.DBMS_RCVMAN version 19.20.00.00 in TARGET database is not current
connected to target database: TESTDB (DBID=1231118758)
connected to recovery catalog database

CAUSE

Once the DBRU/DBRUR is applied  datapatch was not run. While DBRU/DBRUR will update the binary datpatch would ensure the dictionary are also updated

SOLUTION

Crosscheck if datapatch was run.

SET PAGESIZE 100
SET LINESIZE 300
COLUMN status FORMAT A10
COLUMN description FORMAT A40
COLUMN source_version FORMAT A10
COLUMN target_version FORMAT A10

select CON_ID,
TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
PATCH_ID,
PATCH_TYPE,
ACTION,
DESCRIPTION,
SOURCE_VERSION,
TARGET_VERSION
from CDB_REGISTRY_SQLPATCH
order by CON_ID, action_time, patch_id;

Run datapatch if it was not run:

$ORACLE_HOME/OPatch/datapatch -verbose

select * from pdb_plug_in_violations where status <> 'RESOLVED';

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -e -b utlrp -d $ORACLE_HOME/rdbms/admin utlrp.sq

PDB_PLUG_IN_VIOLATIONS

Always check PDB_PLUG_IN_VIOLATIONS for inconsistency between CDB and PDB, and run “datapatch” to resolve it

PDB_PLUG_IN_VIOLATIONS displays information about incompatibilities between a PDB and the CDB to which it belongs.

SQL> select name,cause,type,action 
       from pdb_plug_in_violations 
      where status <> 'RESOLVED';

NAME          CAUSE              TYPE
------------- ----------------   ---------
ACTION
-------------------------------------------
PDB$SEED       SQL Patch        ERROR
Call datapatch to install in the PDB or the CDB

PDB$SEED        SQL Patch       ERROR
Call datapatch to install in the PDB or the CDB

Run ‘datapatch’ again:

$./datapatch -verbose
SQL Patching tool version 12.1.0.2.0 Production on Tue Sep 26 14:16:33 2017
Copyright (c) 2012, 2016, Oracle. All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_103685_2017_09_26_14_16_33/sqlpatch_invocation.log

Connecting to database...OK
Note: Datapatch will only apply or rollback SQL fixes for PDBs
 that are in an open state, no patches will be applied to closed PDBs.
 Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
 (Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of SQL patches:
Patch 21555660 (Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)):
 Not installed in the binary or the SQL registry
Patch 26027162 (Database PSU 12.1.0.2.170718, Oracle JavaVM Component (JUL2017)):
 Installed in the binary registry and CDB$ROOT RACTESTPDB PDB$SEED
Bundle series PSU:
 ID 170814 in the binary registry and ID 170814 in PDB CDB$ROOT, ID 170814 in PDB PDB$SEED, ID 170814 in PDB RACTESTPDB

Adding patches to installation queue and performing prereq checks...
Installation queue:
 For the following PDBs: CDB$ROOT PDB$SEED RACTESTPDB
 Nothing to roll back
 Nothing to apply

SQL Patching tool complete on Tue Sep 26 14:18:39 2017

Check again without issues anymore.

SQL> select * from pdb_plug_in_violations where status <> 'RESOLVED';

no rows selected

Check what patches installed:

SQL>select target_build_description,PATCH_UID,PATCH_ID,ACTION,STATUS,ACTION_TIME,DESCRIPTION from dba_registry_sqlpatch order by ACTION_TIME;