Run a Stored Procedure from Script

server racks on data center

This is an example of how to call a stored procedure from a script.

JDBC Connection

from psdi.security import UserInfo
from psdi.server import MXServer

vsql = "{call sp_update_po (?, ?)}"

mxserver = MXServer.getMXServer()
conKey = mxserver.getSystemUserInfo().getConnectionKey()
cnx = mxserver.getDBManager().getConnection(conKey)

stmt = cnx.prepareCall(vsql)
stmt.setString(1, 9983)    # 1st param
stmt.setString(2, "ACME")  # 2nd param
stmt.executeUpdate(vsql)

stmt.close()
mxserver.getDBManager().freeConnection(conKey)

Note: Be careful with modifying information from MAXIMO objects directly, because it can cause data inconsistency.


If you found my post interesting or useful and just want to say thanks, you can always buy me a coffee.

Leave a Reply