Monday, February 13, 2023

Maximo execute sql scripts without Database access

What ? 
Running DML sql scripts from Maximo UI Automation scripts without write access to database

Why ? 
Some projects won't provide write access to the database. In such cases, we need to find a way to execute update or insert sql statements for our support related tasks. 

Even if we have write access to database, there will be change freeze period between 17th December to 3rd January to block the execution of DML commands. 

How ? 
Create an automation script with Object Launch point code runsqlfile.py




If you are running the script from a cron task, the connectionKey should be retrieved from MXServer instead of implicit variable mbo.
connectionKey = MXServer.getMXServer().getSystemUserInfo().getConnectionKey()
or
connectionKey = mbo.getThisMboSet().getSystemUserInfo().getConnectionKey()

Sample Object Launch point:
Object - Asset ; 
Event Condition - 1=1 or blank



Use Maximo MeaGlobal directory to store the file and read it from the automation script.
  • SaaS Maximo 7.6.x MeaGlobal directory = ./MeaGlobalDirs
  • MAS 8.x  MeaGlobal directory =  /MeaGlobalDirs

Sample sql script runfile.sql











How to run the script ?
Activate the script and launch point to execute the script
Click on the "Test Script" button

Click on "Test" button to run the python script 



Validate the DML scripts in the database
Please disable the Launch Point and Automation Script after running the sql scripts, because it will impact the Maximo functionality on the Asset application. 

Note: Running sql scripts directly into database is not recommended by the Product team. Please do your own due diligence on executing them

No comments:

Post a Comment