# SQLTags in FSQL

**URL:** <https://forum.inductiveautomation.com/t/sqltags-in-fsql/613>\
**Category:** Archived Topics\
**Created:** [March 19, 2008, 10:53pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613 "2008-03-19T22:53:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bds](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bds](https://forum.inductiveautomation.com/u/bds)\
**Post date:** [March 19, 2008, 10:53pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/1 "2008-03-19T22:53:14Z")

</div>

Can I read SQLTags in FSQL?

I want to add noise to a value for a demo. I have OPC tags generating random numbers. I want to multiply this random number times a value from my database. However, I don’t have and can’t buy the ODBC driver for OPC.

If I could read a SQLTag in FSQL, I could get the value from my database that way, and thought that I could do what I needed in an action item.

Alternatively, I suppose I could write a script to run periodically to do this in FPMI, but I have run up against some walls on that route.

Guidance, please. Thanks.

---

<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 19, 2008, 11:27pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/2 "2008-03-19T23:27:57Z")

</div>

You can do this all within the SQLTags system. Make the following tags:

OPCValue = OPC Tag value from your OPC server  
RandValue = DB Tag bound to a SQL Query expression doing a “SELECT RAND()”  
NoiseValue = DB Tag bound to an expression that is OPCValue \* RandValue

Hope this helps,

---

<div class="post-metadata">

**Author:** ![bds](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bds](https://forum.inductiveautomation.com/u/bds)\
**Post date:** [March 20, 2008, 9:42pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/3 "2008-03-20T21:42:23Z")

</div>

I would have thought that. In fact, I tried it, to no avail.

I have two SQLTags. One is reading a value from my database, the other is simulator data from KepServerEX. Both show up as good data in the SQLTags Browser.

A third SQLTag multiplies them.

```auto
{[~]Entegrity/Random/Random1A}*{[~]Entegrity/Selawik/WT1/_History/WS}
```

This tag contains null data and quality is “expression-eval-error”. All are floats.

---

<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 20, 2008, 9:46pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/4 "2008-03-20T21:46:57Z")

</div>

You should get details on the expression eval error in the diagnostics page (help \> diagnostics)

---

<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 21, 2008, 3:33am UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/5 "2008-03-21T03:33:09Z")

</div>

I saw the error report that you submitted about this - are you sure both tags are numeric? Maybe one is a string by mistake?

You could try throwing a toDouble() cast around both tags, let us know if that helps.

---

<div class="post-metadata">

**Author:** ![bds](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bds](https://forum.inductiveautomation.com/u/bds)\
**Post date:** [March 21, 2008, 3:31pm UTC](https://forum.inductiveautomation.com/t/sqltags-in-fsql/613/6 "2008-03-21T15:31:31Z")

</div>

All were float4. When I changed the random number tags to float8, all is well. This even though the SQLTag Browser shows good data quality with either float4 or float8.
