IBM Maximo: Cleanup WOGEN table
WOGEN table data growing exponentially. Is very important to cleanup this table
Details here: WOGEN table data growing exponentially
Create a Crontask
Automation Script - Definition
1) Navigate to the System Configuration > Platform Configuration > Automation Scripts application. 2) From the Select Action menu, choose the Create > Script option. 3) Populate the fields:
- Script: MAX_CLEANUP_WOGEN
- Description: Automation Script to cleanup WOGEN table
- Script Language: python
- Log Level: ERROR
- Source: <put source code below>
4) Click the Create button to create the new script
Automation Script - Source Code
# # MAX_CLEANUP_WOGEN Automation Script called from a Cron Task # this script cleanup WOGEN table # from java.lang import System from psdi.server import MXServer from psdi.util.logging import MXLoggerFactory mxserver = MXServer.getMXServer() logger = MXLoggerFactory.getLogger("maximo.maximodev") def string_to_dict(input_string): res_dict = {} pairs = input_string.split(',') for pair in pairs: key, value = pair.split('=') if value is not None: res_dict[key.lower()] = value return res_dict # Execute delete statement def execDelete(days, numrows): logger.debug("MAX_CLEANUP_WOGEN - execDelete - start") sql = 'delete from WOGEN where rundate < (sysdate-' + days + ') and rownum <= ' + numrows conKey = mxserver.getSystemUserInfo().getConnectionKey() con = mxserver.getDBManager().getConnection(conKey) try: stmt= con.createStatement() stmt.executeUpdate(sql) stmt.close() con.commit() except: print('MAX_CLEANUP_WOGEN - execDelete - exception') finally: mxserver.getDBManager().freeConnection(conKey) # ======================== main ======================== logger.info('MAX_CLEANUP_WOGEN start script -- running') print('MAX_CLEANUP_WOGEN start script -- running') # Get the variables from the cron task arguments days = '1' numrows = '100' if arg: arg_dict = string_to_dict(arg) if 'days' in arg_dict: days = arg_dict['days'] if 'numrows' in arg_dict: numrows = arg_dict['numrows'] print('MAX_CLEANUP_WOGEN days = ' + days + '; numrows = ' + numrows ) execDelete(days,numrows) logger.info('MAX_CLEANUP_WOGEN end script')