# Virtual sql tag to auto increment on OPC tag change

**URL:** <https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442>\
**Category:** Ignition\
**Created:** [November 19, 2012, 3:00pm UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442 "2012-11-19T15:00:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [November 19, 2012, 3:00pm UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/1 "2012-11-19T15:00:26Z")

</div>

I am looking for a way to create a virtual sql tag and have that tag auto increment any time a select OPC tag value transitions from 0 to 1.

Is this possible? Can you point me to this documentation if already available? I know I could do this inside the PLC, but I would like to be able to create this tag in ignition without having to modify any OEM settings on our equipment.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [November 19, 2012, 3:06pm UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/2 "2012-11-19T15:06:24Z")

</div>

That’s what the “event meter” option of OPC items in a transaction group does.

Another approach would be to use a script that increments your counter on a value change.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/c2f5c71043f9b9ad0a7e97eac9b515388a69d4db.png)

---

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [November 20, 2012, 6:59am UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/3 "2012-11-20T06:59:59Z")

</div>

Thank you. I used your meter and it works.

In my head I felt like I could create an integer tag/variable and increment that as the other tag changed. Using the historian and alerting if that tag began to increment at a high rate.

could you explain the other in detail if you have time.

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [November 20, 2012, 7:05am UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/4 "2012-11-20T07:05:41Z")

</div>

Sure - you could create another tag and increment that one on value change of the first. Determining the rate of change of this is also possible, but applying that to this approach does not strike me as clean. I would approximate the rate by (total change/time slice). You can alert/record this as well.

I’m curious what other people recommend for this.

---

<div class="post-metadata">

**Author:** ![ecujak](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@ecujak](https://forum.inductiveautomation.com/u/ecujak)\
**Post date:** [November 28, 2012, 9:14pm UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/5 "2012-11-28T21:14:24Z")

</div>

Me too. Is there a way to create a virtual tag, that doesn’t really update from anywhere but inside ignition. A tag with the same functions as all other tags?

Is there a way to do this while keeping the comm read only?

I am sure I didn’t word this correctly.

---

<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:** [November 28, 2012, 10:01pm UTC](https://forum.inductiveautomation.com/t/virtual-sql-tag-to-auto-increment-on-opc-tag-change/5442/6 "2012-11-28T22:01:53Z")

</div>

Well you can create memory tags which are only used within Ignition.
