Check DB vs tag values, run update if different or

This is a bad idea, you should be using Gateway Tag Change events. There are a couple of methods to do this, if the script is generalized enough you can run the same script for all of the tags and just assign those tags to the tag change event (Gateway Tag Change Events can be triggered by multiple tags).

You could also generate a top level list of tags, and at a trigger run the script which does all of the work for all of the tags at once.

Reference for why this is a bad idea:

https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts

As for the script that you provided:

  • Perhaps you know this, but if not, system.tag.readBlocking() takes a list of tag paths.
  • If the tags are mostly static, I wouldn't see the need to read their values more than once.
  • system.db.runUpdateQuery() will return the number of row effected by the query, you can check that to insure that "something has changed" in the db.
  • This data1 != data2 will not work as written. Verifying equality of datasets is a complex operation, if you have access to @PGriffith's Ignition Extentions Module, it has a function that will check the equality of datasets. Otherwise you will need to script that operation.
  • I would recommend using Named Queries rather than hard coding the queries as you have shown, either will work though.