# SQL Tag editor

**URL:** <https://forum.inductiveautomation.com/t/sql-tag-editor/1520>\
**Category:** Ignition\
**Created:** [February 9, 2010, 7:20pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520 "2010-02-09T19:20:53Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![david\_mccutchen](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@david\_mccutchen](https://forum.inductiveautomation.com/u/david_mccutchen)\
**Post date:** [February 9, 2010, 7:20pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/1 "2010-02-09T19:20:53Z")

</div>

We frequently use the SQL tag editor from the freebies for FPMI. With realtime internal tags how will this work since they are not stored in the DB. It is very beneficial for us to edit these from the runtime.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 9, 2010, 7:49pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/2 "2010-02-09T19:49:18Z")

</div>

Great question. We’ve talked about this a bit internally, and we think the best option would probably be for us to simply have a tag editor component that could be used within the Client runtime.

The other option would be for us to expose a more robust tag editing scripting API, and then you could roll your own window that would use this API rather than the direct database interactions of the past. This is probably more likely in the short term.

In the meantime, you can do a bit of this by simply writing to the tag’s properties, but we are aware that this doesn’t really work for the more complex properties like alerting config.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [March 9, 2010, 8:13pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/3 "2010-03-09T20:13:12Z")

</div>

We have a customer that wants to be able to change analog alarm limits without using the designer. ie from within the app. I was looking to see if I could change the limits on a SQLTag via scripting.

Does this:

[quote=“Carl.Gould”]  
In the meantime, you can do a bit of this by simply writing to the tag’s properties, but we are aware that this doesn’t really work for the more complex properties like alerting config.[/quote]

mean I have to look at other ways?

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [March 9, 2010, 9:43pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/4 "2010-03-09T21:43:27Z")

</div>

One way to expose the alarm limits is to create DB Tags for the low or high setpoints of each analog alarm state and set the states to Tag-Driven. It could create a lot of extra tags for you to manage, but isn’t unbearable.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 11, 2010, 5:06pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/5 "2010-03-11T17:06:13Z")

</div>

Yeah, there are really two ways to have runtime-settable alert limits:

1. Use a DB SQLTags Provider so all of your tag definitions are in an external database, and modify those definitions (ala FactorySQL & FactoryPMI)

2. Set up your alert limits to reference other tags, and the let the user’s modify those tags (Good for when only a small number of tags’ alerts need to be configurable)

The 3rd option is to wait for the upcoming system.tag.alterTagAlerts() function, which should be included in 7.1.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [March 12, 2010, 7:50pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/6 "2010-03-12T19:50:13Z")

</div>

Further question about SQLTags.

Our data is placed in the database by our own software which is not OPC. To date we have not used SQLTags for this reason. So I’m trying to figure out if we should start.

I’m guessing that SQLtags poll the db for changes. If I create a couple hundred SQLTags for the analog points I want to alarm/historize, will my db be hit with hundreds of selects a poll cycle? ie: one select per point?

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 12, 2010, 9:06pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/7 "2010-03-12T21:06:38Z")

</div>

Each time the SQLTags system polls the database for changes (several times a second), it is basically saying: “select everything where valuechange\>last check”. So, 2 points: 1) There is only 1 query per cycle and 2) It’s selecting based on an indexed timestamp, so the query is very fast.

Would you be driving the values from your own application, or are you just asking in general?

Regards,

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [March 15, 2010, 5:25pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/8 "2010-03-15T17:25:02Z")

</div>

Yes, the values are being driven from our application.

How does that work when the tags are bound to an sql?

Or have I missed something about defining a tag when the datapoint is in a database? ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

Should I bind the tag to an expression? Will it be monitored if there is no client running?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 15, 2010, 6:53pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/9 "2010-03-15T18:53:07Z")

</div>

I think Colby was assuming that you would be using db tags that weren’t bound to anything, and have your application “drive” them directly by interfacing with our sqlt\_core table. If you want your tags’ values to be calculated by using a custom SQL query expression per tag, then yes, they will have to poll those queries independently.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [March 15, 2010, 9:35pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/10 "2010-03-15T21:35:27Z")

</div>

Now that’s an interesting idea. You mean I can create a table full of tags that SQLBridge polls, but that a 3rd party (eg: my app) can update.

I totally missed that while reading the documentation. That might actually work.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 15, 2010, 10:50pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/11 "2010-03-15T22:50:45Z")

</div>

Well, it’s not really something we highlight too much, so it’s understandable you wouldn’t think about it after reading the manual. However, with “external sqltags” as they’re called now, everything is in the database, so you could technically drive them yourself.

Basically, if you have data being driven by your own app, you have a few choices:

1. Pull the data in directly through db bindings on component properties, or dynamic dataset properties that pull in blocks of data.
2. Create SQLTags that run queries to get the data.
3. Drive the SQLTags model yourself.

Which method you use depends on a variety of factors- how you want to use the data, how much data you have, and how easily it is for you to modify your driving application. #1 and #2 are done purely from Ignition and work with your current db/application structure. #3 will be much more efficient if there is a lot of data.

SQLTags is designed to support multiple “drivers”- previously these were multiple FactorySQL nodes writing driving values in a single database, and now are multiple Ignition/SQL Bridge nodes using the “external database driver”. Your application would just be another driver. You’ll define tags in the SQLTags schema, and assign them a “driver name” that tells the other nodes that someone else is driving the value. Then, in your app, whenever a value changes you just set it in the correct value column, and update “valuechange” to be the current time. This tells everyone watching that the value has been changed.

We can give you a bit more info if this sounds like the road you want to go down.

Regards,

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [March 17, 2010, 10:36pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/12 "2010-03-17T22:36:31Z")

</div>

Currently we are using option 1.

For a bunch of reasons we are looking at option 3.

What do I have to do to set the the required tables?  
Feel free to contact me offline if you don’t want to go into details here

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 18, 2010, 1:33am UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/13 "2010-03-18T01:33:31Z")

</div>

Because of increased interest in that recently, I think I’m going to throw together a white paper tomorrow that outlines how to drive your own tags. I’ll let you know when it’s available.

---

<div class="post-metadata">

**Author:** ![bryan\_cook](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@bryan\_cook](https://forum.inductiveautomation.com/u/bryan_cook)\
**Post date:** [March 18, 2010, 12:42pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/14 "2010-03-18T12:42:05Z")

</div>

I’d be very interested in this white paper as well …

---

<div class="post-metadata">

**Author:** ![ISDProj](https://avatars.discourse-cdn.com/v4/letter/i/58956e/32.png) [@ISDProj](https://forum.inductiveautomation.com/u/ISDProj)\
**Post date:** [March 19, 2010, 3:14am UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/15 "2010-03-19T03:14:04Z")

</div>

Will the white paper be made available to forum members?  
I too am interested in this.

Peter

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 21, 2010, 1:34am UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/16 "2010-03-21T01:34:32Z")

</div>

It’ll be up on Monday. It’ll be available to anyone who wants it, I’ll post a link when it’s up.

Regards,

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 22, 2010, 4:28pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/17 "2010-03-22T16:28:49Z")

</div>

See [this forum post](http://www.inductiveautomation.com/forum/viewtopic.php?f=25&t=5054) for the paper.

Regards,

---

<div class="post-metadata">

**Author:** ![david\_mccutchen](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@david\_mccutchen](https://forum.inductiveautomation.com/u/david_mccutchen)\
**Post date:** [July 5, 2010, 7:07pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/18 "2010-07-05T19:07:45Z")

</div>

Any update on this?

[quote]Great question. We’ve talked about this a bit internally, and we think the best option would probably be for us to simply have a tag editor component that could be used within the Client runtime.  
[/quote]

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 6, 2010, 4:00pm UTC](https://forum.inductiveautomation.com/t/sql-tag-editor/1520/19 "2010-07-06T16:00:08Z")

</div>

No, no updates. The feature request is pending in the system, but it isn’t a very high priority right now.
