Hello. I am currently using 8.1.17 and am using tag event scripts to write to my database. IT has informed me that we will be changing over our database with a newer one and the tables that I am currently writting to will be changed. Can i try my database name to a memory tag and use it as a variable in my update? In the script below i would like to change “Epics” to the dbConn that i have marked out in my variable list. I have tried but cannt get it to work. Any help would be greatly appreciated.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
“”"
Fired whenever the current value changes in value or quality.
Arguments:
tag: The source tag object. A read-only wrapper for obtaining tag
properties.
tagPath: The full path to the tag (String)
previousValue: The previous value. This is a "qualified value", so it
has value, quality, and timestamp properties.
currentValue: The current value. This is a "qualified value", so it has
value, quality, and timestamp properties.
initialChange: A boolean flag indicating whether this event is due to
the first execution or initial subscription.
missedEvents: A flag indicating that some events have been skipped due
to event overflow.
"""
if previousValue.value != currentValue.value and initialChange == False:
plant = system.tag.read("[default]CRP Checklist/QueryBuilingTags/Plant").value
Furnace =system.tag.read("[default]CRP Checklist/QueryBuilingTags/Furnace").value
line = system.tag.read("[default]CRP Checklist/QueryBuilingTags/Line").value
CheckListName = system.tag.read("[default]CRP Checklist/QueryBuilingTags/CheckListName").value
TagName = system.tag.read("[default]CRP Checklist/PCheck2Value.Name").value
TagValue = system.tag.read("[default]CRP Checklist/PCheck2Value").value
TagDataType = system.tag.read("[default]CRP Checklist/QueryBuilingTags/TagDataType").value
DateEntered = system.tag.read("[default]CRP Checklist/QueryBuilingTags/DateEntered").value
ScheduledTime = system.tag.read("[default]CRP Checklist/PCheck2Time").value
ActualTime = system.tag.read("[default]CRP Checklist/PCheck2Value.Timestamp").value
#bdConn = System.tag.read("[default]CRP Checklist/QueryBuilingTags/Database").value
system.db.runPrepUpdate("INSERT INTO foy.SCM_Checklist (PlantID, Furnace, Line, CheckListName, TagName, TagValue, TagDataType, DateEntered, ScheduledTime, ActualTime) VALUES (?,?,?,?,?,?,?,?,?,?)",[plant, Furnace, line, CheckListName, TagName, TagValue, TagDataType, DateEntered, ScheduledTime, ActualTime],"Epics")