# Alarms history table comments to DB

**URL:** <https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177>\
**Category:** Ignition\
**Created:** [March 20, 2012, 2:59pm UTC](https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177 "2012-03-20T14:59:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [March 20, 2012, 2:59pm UTC](https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177/1 "2012-03-20T14:59:31Z")

</div>

Hi

I have an alarms history table populated by queryAlertHistory, where I have Notes column enabled and editable. I would like to store entered text for corresponding alarm in the database. How is it possible?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 20, 2012, 3:41pm UTC](https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177/2 "2012-03-20T15:41:57Z")

</div>

Well, once you make the column editable you need to figure out the script that writes information back to the database on the cellEdited event of the table. When a cell is modified the cellEdited event fires letting you know:

event.newValue  
event.row  
event.column

Your script would look something like:`value = event.newValue
row = event.row
col = event.column
data = event.source.data
id = data.getValueAt(row, "id")
if col == 1: # whatever the note column is
    system.db.runPrepUpdate("......", [id]) # whatever the query is INSERT or UPDATE`Hope that helps you get started.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [April 4, 2012, 6:26am UTC](https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177/3 "2012-04-04T06:26:44Z")

</div>

Thanks.  
So first thing I have to add Comments column to alert\_log table?

And for “id = data.getValueAt(row, “id”)”,  
there is no such “id” column in component “Table”, what does it stand for?

Thank you.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 4, 2012, 3:13pm UTC](https://forum.inductiveautomation.com/t/alarms-history-table-comments-to-db/4177/4 "2012-04-04T15:13:46Z")

</div>

Right, I would recommend doing your own SQL query so you can bring back the id column. You can bind the data property of the table to a query like:`SELECT id, display_path, active_timestamp, ...... FROM alert_log WHERE active_timestamp BETWEEN '2012-01-01 00:00:00' AND '2012-01-01 23:59:59' ORDER BY active_timestamp ASC`You may want to change it up a little. Let us know if you have any more questions.
