Run query in UDT

Can I run an Update query as an expression tag like

runScript(app.Winchester.DowntimeQuery.query("MOTOR_1008"), 1000)

then the script is:

def query(Motor): import system run = 5 faults = 6 system.db.runUpdateQuery("UPDATE Conveyordesc SET Runtime = '%s', Faults = '%s' WHERE motorID = '%s'" % (run, faults, Motor), 'SQLServer') return 0

I’d like to be able to consistantly update my table for each UDT instance of motors

You can’t call app script function inside of tags. Tags are stored on the gateway and executed there outside of a project. So they don’t have access to those functions. However, you should be able to do a runScript calling the system function:runScript("system.db.runUpdateQuery(\"UPDATE Conveyordesc SET Runtime = '5', Faults = '6' WHERE motorID = 'MOTOR_1008'\", 'SQLServer')", 1000)You can put in dynamic values like this:runScript("system.db.runUpdateQuery(\"UPDATE Conveyordesc SET Runtime = '5', Faults = '6' WHERE motorID = '" + {Path/To/Tag} + "'\", 'SQLServer')", 1000)

thanks Travis