# Updating Tables

**URL:** <https://forum.inductiveautomation.com/t/updating-tables/8324>\
**Category:** Ignition\
**Created:** [April 16, 2014, 4:59pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324 "2014-04-16T16:59:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [April 16, 2014, 4:59pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/1 "2014-04-16T16:59:49Z")

</div>

Hey,  
So an annoying glitch got uncovered. If someone is editing a column on a table and someone else adds a new row to the table, the table being edited gets updated and the edits will get put onto the row above. Is there a way to get around this happened?

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 16, 2014, 7:18pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/2 "2014-04-16T19:18:34Z")

</div>

If your polling mode is Relative, then it will continue to refresh the data. Try changing it to OFF.

![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f7aa626a8a61c0256e4d173a8e1dfb3197e8069.jpeg)

CORRECTION: It sounds like you are not using Unique IDs in whatever place you are storing and editing the shared data. Create a PRIMARY KEY in your SQL Table, or find some other unique way to represent each row in your table.

---

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [April 16, 2014, 7:24pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/3 "2014-04-16T19:24:33Z")

</div>

Yes that could work. But the table needs to be updating. I wish it were that easy.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 16, 2014, 7:25pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/4 "2014-04-16T19:25:36Z")

</div>

Sorry, see correction above.

---

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [April 16, 2014, 7:31pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/5 "2014-04-16T19:31:08Z")

</div>

Here is the table, and the script that is used to save the notes.

[code]"""  
Allows for updating on the table.  
“”"  
row = event.row  
column = event.column  
columnName = event.source.data.getColumnName(column)  
newValue = event.newValue

if columnName == ‘Note’:  
if newValue == “”: # User changed it to an empty note. Delete the Comment  
# Remove from Runtime db  
query = “DELETE FROM Comment WHERE ID = ?”  
values = [event.source.runtimeID]  
system.db.runPrepUpdate(query,values,“MES\_Runtime”)  
# Remove from Analysis db  
query = “DELETE FROM PROD\_Comment\_Summary WHERE ID = ?”  
values = [event.source.analysisID]  
system.db.runPrepUpdate(query,values,“MES\_Analysis”)  
# Update table  
system.db.refresh(event.source,“data”)  
else: # User changed it to another string. Update the comment.  
# update Runtime db  
query = “UPDATE Comment SET Note = ? WHERE ID = ?”  
values = [newValue, event.source.runtimeID]  
system.db.runPrepUpdate(query,values,“MES\_Runtime”)  
# update Analysis db  
query = “UPDATE PROD\_Comment\_Summary SET Note = ? WHERE ID = ?”  
values = [newValue, event.source.analysisID]  
system.db.runPrepUpdate(query,values,“MES\_Analysis”)  
elif columnName == “IsSticky”:  
# update Runtime db. Note: there is no editing needed in the Analysis db  
query = “UPDATE Comment SET IsSticky = ? WHERE ID = ?”  
values = [newValue, event.source.runtimeID]  
system.db.runPrepUpdate(query,values,“MES\_Runtime”)[/code]

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 16, 2014, 7:50pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/6 "2014-04-16T19:50:15Z")

</div>

Try changing your DELETE statements to UPDATE statements instead. Something like:

```auto
...
      query = "UPDATE Comment SET Note = ? WHERE ID = ?"
      values = [None, event.source.runtimeID]
...
```

---

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [April 16, 2014, 10:40pm UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/7 "2014-04-16T22:40:14Z")

</div>

the only reason the delete statement is in there is when they make it a blank string. if it is anything other then that it pushes it to the update statement.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [April 17, 2014, 12:06am UTC](https://forum.inductiveautomation.com/t/updating-tables/8324/8 "2014-04-17T00:06:19Z")

</div>

I am assuming that the trouble is since the data is being updated, the “selectedrow” property is being changed when someone adds something to the table. perhaps, instead of using an editable table, popping up a window that allows you to make the edits, then send them to the database would solve your issue.
