If your are getting:

ORA-39125: Worker unexpected fatal error in KUPW$WORKER.UNLOAD_METADATA while calling DBMS_METADATA.FETCH_XML_CLOB [TAB
LE:"UNIUS"."SBA_E_SYSTEM_H"]
ORA-01801: date format is too long for internal buffer

during expdp or dbms_metadata exports, it’s because there are stored incorrect date values in the dictionary.

The following plsql should _not_ report any tables, if yes you may need to correct the values, see below.


declare
   n number;
begin
   for x in(
      select * from dba_tab_columns
         where column_name = 'ANALYZETIME'
            and owner='SYS'
            and table_name like '%$'
   )
   loop
      N := 0;
      EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM '
         || X.TABLE_NAME || '
         WHERE to_char(analyzetime,''DD-MON-YY'') = ''00-000-00'''
         INTO N;

      IF N > 0 THEN
         dbms_output.put_line('Problem: ' || X.TABLE_NAME);
      END IF;

   end loop;
end;
/

Problem: TABSUBPART$

To fix the table TABSUBPART$ run the following update: (!!! FIRST CONSULT ORACLE SUPPORT !!!)

-- !!! Be sure that you have a valid bakup. !!!
connect / as sysdba
SQL>shutdown immediate
SQL>startup restrict
SQL>update tabsubpart$ set analyzetime = sysdate where to_char(analyzetime,'DD-MON-YY') = '00-000-00';
SQL>commit;
SQL>shutdown immediate
SQL>startup

Please use this at your own risk, you should always consult Oracle support before doing anything to your database.