AUTOMAINT_SET_POLICYFILE procedure can fail with a misleading error message.
The AUTOMAINT_SET_POLICYFILE procedure can fail with a misleading error message because of lack of table privileges. This usually happens if the database has been created by restoring the db from another environment (different db/instance name) and the privileges on systools.policy are not carried out.
Here is the the error:
db2 "call sysproc.automaint_set_policyfile('MAINTENANCE_WINDOW', 'DB2MaintenanceWindowPolicy.xml')"
SQL1438N An internal error occurred while processing the XML automated
maintenance policy configuration file or LOB parameter passed to
AUTOMAINT_SET_POLICY or AUTOMAINT_SET_POLICYFILE. SQLSTATE=5U0ZZ
***note that in this case the DB2MaintenanceWindowPolicy.xml has no code errors.
Here is the fix:
db2 grant all on systools.policy to <user id>
DB20000I The SQL command completed successfully.
db2 "call sysproc.automaint_set_policyfile( 'MAINTENANCE_WINDOW', 'DB2MaintenanceWindowPolicy.xml')"
Return Status = 0