Named Queries in Value Changed Tag Event Scripts

Good day,

I am having difficulty in executing a Named Query in a Value Changed Tag Event Script.
So this idea is that when my control step changes it populates a database for reporting.

When I test the name query it works perfectly.
I have confirmed that all values in the Tag Event Script is read correctly.

What am I missing here?


You can try to explicitly define the variables within the runNamedQuery function. The system.db.runNamedQuery() function acts differently when it is called from a Global Scope as opposed to a client scope.

system.db.runNamedQuery(project = "Lancewood_George", path = "StepLog1", parameters = params)

@gerhard.louw Any luck? I’m trying to do the same thing but having a hard time getting it to the database. TIA

Any update about this?

I want to do the same, as run a Named Query “Insert” on a tag value when it changes to high.

Tag change events run in gateway scope, so you must include the project name, something like this:

params = {"val": 1}
system.db.runNamedQuery("ProjectName", "QueryName", params)

Also make sure your named query type is set to update, and check the gateway log if it doesn’t work, any error you find there will help track down the issue.