NOTE: It is critical that this patch is installed before attempting an upgrade.
https://support.oracle.com/rs?type=doc&id=2525596.1 Database Upgrade to 12.2, 18c, 19c fails with ORA-01422, ORA-06512 for SYS.DBMS_STATS
Login as 'oracle' on the target server with the 12.2 environment set.
opatch lsinventory | grep 29213893
Download the patch from Oracle and place the zip file in /u01/img/122010
Download the patch from Oracle (as above) to /u01/img/122010 on your Local Management Server (if it is not already there).
mkdir -p /u01/img/122010
scp -pr ${PATCH_SERVE}:/u01/img/122010/p29213893_122010_Generic.zip /u01/img/122010
cd /u01/img/122010
rm -rf /u01/img/122010/29213893
find . -name "p29213893_122010_Generic.zip" -exec unzip {} \;
rm *.zip
cd /u01/img/122010/29213893
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
cd /u01/img/122010/29213893
opatch apply -silent -ocmrf /u01/img/ocm.rsp
opatch lsinventory | grep 29213893
cd /u01/img/122010/29213893
opatch rollback -id 29213893
opatch lsinventory | grep 29213893