I have a table that is pulling in alert info based on a db query from the sqlt_as table. I’m trying to allow editing directly from the table but my problem is that the Table I’m pulling the info into has 3 Columns - Alarm, Type, and Setpoint. The Setpoint (whether hi or lo) is based on the Type (*flag,0-digital 2-analog hi or 8-analog lo). My question is how could I base the query update for the Setpoint column on what alarm ‘Type’ is selected in the table? Forgive me if I’m asking this question wrong I’m still fairly new to Ignition…
Here is the update query for the table we have so far:
table = event.source.parent.TableName
pk = event.source.parent.PrimaryKey
colName = event.source.data.getColumnName(event.column)
colNamelow = “low”
colNamehigh = “high”
Handle the case where there are multiple primary keys
pks = [x.strip() for x in pk.split(",")]
where=""
for key in pks:
where += key + "=? AND "
remove trailing AND
where = where[:-5]
query = “UPDATE %s SET %s=? WHERE %s”% (table, colName, where)
params = [event.newValue]
for key in pks:
params.append(event.source.data.getValueAt(event.row, key))
fpmi.db.runPrepStmt(query, params)