# Error when using \`system.tag.storeTagHistory\`

**URL:** <https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 12, 2023, 8:36pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928 "2023-06-12T20:36:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [June 12, 2023, 8:36pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/1 "2023-06-12T20:36:49Z")

</div>

I'm working on an application similar to the [CSV to Tag Converter](https://inductiveautomation.com/exchange/2345/overview) on the Exchange, but in Perspective.

I keep running into issues using the `system.tag.storeTagHistory` function (I'm on v8.1.25 - it was added back in v8.1.8 IIRC). Here is what I'm testing with:

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

```auto
historyprovider = "LocalDB"
tagprovider = "default"
paths = ["[default]test", "[default]test", "[default]test"]
values = [1.23, 4.56, 7.89]

system.tag.storeTagHistory(historyprovider, tagprovider, paths, values)

```

Here is what I get in the gateway logs:

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/4/644684710ee3dde0821dd5199227dd3aaa8eadca.png)

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

Any help or guidance is greatly appreciated, I feel like I've been hitting a brick wall for several days now...

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [June 13, 2023, 6:20am UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/2 "2023-06-13T06:20:17Z")

</div>

I would guess you don't need the [default] on the tag paths.. They aren't used on the documentation [system.tag.storeTagHistory - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.tag.storeTagHistory)

You also need to state the tag path multiple times to store more than one data point, in your screenshot you only have 1 path

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [June 13, 2023, 2:33pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/3 "2023-06-13T14:33:46Z")

</div>

Good catch! That may be one of the problems - yesterday I created a new DB table called TagHistory and used that as the historical tag provider AND IT WORKED?! Now I'm more confused as to why it wasn't working earlier.

The setup I had on the DB side (SQL Server) was a simple testing database I created. I ran the Vision app I got off of the Exchange, where it generated the historical tag records, then deleted all of those tables so I can try again, and it didn't work after that.

I will post the eventual resolution in this thread.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 13, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/4 "2023-06-13T15:21:54Z")

</div>

> [@YF129701](#):
>
> then deleted all of those tables so I can try again

That seems like the root of the problem.

My educated guess:  
Standard history storing operations ensure that the tables exist in the database. `system.tag.storeTagHistory` may be taking a 'shortcut' code path that does not, so when you manually deleted all the historian tables nothing was putting them back in place. Manually storing history to a new provider 'suddenly' works.

That's the only explanation I can come up with that makes sense for what you've described.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [June 13, 2023, 3:26pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/5 "2023-06-13T15:26:13Z")

</div>

What you're describing seems accurate and is probably what's happening... Is there a way to avoid creating new databases every time I want to run a test? This seems... well, sort of suboptimal, though there is probably a good reason why it happens.

**EDIT** : Just saw you made changes on the docs page for this function and also noticed that the cache needs to be cleared - just deleting the db tables doesn't reset anything. Is there a way to clear the cache without restarting the Ignition service?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 13, 2023, 3:28pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/6 "2023-06-13T15:28:30Z")

</div>

You could simply truncate the `sqlth_*` tables, and drop only the `sqlt_data_x_timestamp` columns.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 13, 2023, 3:32pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/7 "2023-06-13T15:32:12Z")

</div>

> [@YF129701](#):
>
> Just saw you made changes on the docs page for this function

Just fixing a typo 🙂

> [@YF129701](#):
>
> the cache needs to be cleared

Which cache are you referring to?

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [June 13, 2023, 3:42pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/8 "2023-06-13T15:42:49Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/601c5940ee41fc5ef1f86c5d68b4ff2e3a6e37a6.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 13, 2023, 6:43pm UTC](https://forum.inductiveautomation.com/t/error-when-using-system-tag-storetaghistory/74928/9 "2023-06-13T18:43:11Z")

</div>

If you do an edit -\> save on the history provider you're targeting it should clear that cache.
