# Log tag values to database table

**URL:** <https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949>\
**Category:** Ignition\
**Created:** [November 5, 2025, 2:43am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949 "2025-11-05T02:43:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 5, 2025, 2:43am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/1 "2025-11-05T02:43:06Z")

</div>

Hi Forum,

Given two tags tag1, tag2, and a workorder.

On the production floor, when a process is running (indicated by a running tag).  
Every time tag1 value change, ignition needs to write both tag1 and tag2 values onto a database table including workorder.  
Such that, user could query these data per workorder and display on xy chart.

I wonder which is best:

1. Record the start and end time of the process, and use it to query tag history?
2. Use a gateway tag change script, run a write query?
3. Can SQL Bridge even do this requirement?

---

<div class="post-metadata">

**Author:** ![Jasmine\_Quick](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jasmine_quick/32/80380_2.png) [@Jasmine\_Quick](https://forum.inductiveautomation.com/u/Jasmine_Quick)\
**Post date:** [November 5, 2025, 3:05am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/2 "2025-11-05T03:05:04Z")

</div>

I would use a transaction group to do this, with the trigger condition being the tag1 changing value

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [November 5, 2025, 5:02am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/3 "2025-11-05T05:02:54Z")

</div>

As Jasmine mentioned, this is where a transaction group (SQL Bridge) would work well, especially if you haven't done this type of thing before.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 6, 2025, 8:48pm UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/4 "2025-11-06T20:48:11Z")

</div>

Is it a good practice to only log Tag Values with Good Quality?

Should I log the value with quality along with it?

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [November 6, 2025, 9:04pm UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/5 "2025-11-06T21:04:46Z")

</div>

I would suggest that a tag with bad quality is junk data and should be left out of the database.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 7, 2025, 8:38am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/6 "2025-11-07T08:38:02Z")

</div>

If you're not already using transaction groups, I'm not sure this use case justifies adding an extra module. If you need to use this pattern for a lot of tags, then maybe, and even then with a properly constructed tag hierarchy, transaction groups are not that helpful..

You can just use a gateway tag change event, monitoring tag 1, and insert both tags values when the event is triggered.  
Add some validation and filtering logic if needed, and you got yourself a simple script that does exactly what you need.

The only thing that's unclear to me is where you find the workorder.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 7, 2025, 2:58pm UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/7 "2025-11-07T14:58:52Z")

</div>

> [@pascal.fragnoud](#):
>
> You can just use a gateway tag change event,

I agree with you, since I know python and writing query, I find that transaction group also do the same thing under the hood. And it give me more flexibility using python.  
I will also take this opportunity to look at transaction group, I forgot about what is this all about.

> [@pascal.fragnoud](#):
>
> The only thing that's unclear to me is where you find the workorder.

Is also a tag with string data type.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 8, 2025, 4:19am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/9 "2025-11-08T04:19:06Z")

</div>

I come to conclude that, using transaction group will provide many benefits.  
I need help though.  
I watch all the videos, but still confuse how to configure transaction group according to client requirement:

Below are the items:

1. isRunning tag
2. distance tag (int)
3. workorder tag (string)
4. val\_1
5. val\_2

The Logic:  
if Running tag is True.  
Every time distance tag change  
then log item 2 to item 5 to database.

I am confuse particularly on Execution Timer.  
I watched that, Execution Timer will take precedence:  
What if Execution timer is slower than distance tag increment?

How do I set this up in Transaction group.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 8, 2025, 5:30am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/10 "2025-11-08T05:30:02Z")

</div>

Try this (I Haven’t tested it):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/3/d33e6d829676037c7786cc1351586c7874ba50e1.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf258fa7d355d26f79593385d6cf498c7e72d617.png)

> **[Trigger – On Value Change Video at Inductive University](https://inductiveuniversity.com/videos/trigger-on-value-change/8.3)**
>
> Learn how to configure a Transaction Group to only trigger when a value has changed, using either the Timer or Schedule option of the Execution Scheduling setting.

This video and the next one are the ones you want.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 8, 2025, 5:31am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/11 "2025-11-08T05:31:20Z")

</div>

> [@Eugene49](#):
>
> What if Execution timer is slower than distance tag increment?

Set your execution time to the same rate as what you are polling the distance tag.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 8, 2025, 5:36am UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/12 "2025-11-08T05:36:22Z")

</div>

> [@Matrix\_Engineering](#):
>
> This video and the next one are the ones you want.

Thanks, i will try.  
I got confused on "Run Always Expression and Trigger Expression" vs the trigger tab.

I guess just a matter of getting familiar.

Edit:  
I now got clear on my confusion.  
On item table: Run Always and Trigger refers to the expression being executed always or once when triggered. And not referring to the Running or triggering the group to log.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [November 8, 2025, 9:56pm UTC](https://forum.inductiveautomation.com/t/log-tag-values-to-database-table/111949/13 "2025-11-08T21:56:50Z")

</div>

Thanks.  
I got it.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/d/1d1c2f9b9619bfc5e867cc228cb33fd7b137642c.png)
