system.tag.storeTagHistory - Creating New Tag IDs and acting funny

Having worked through this pretty extensively with support, here is what seemed to be the solution:

It was recommended that I update to 7.9.9 because there were some changes to the storeTagHistory() function somewhere in there. No problem, upgrade completed.

Since I am storing tag history from before the point was created, it is EXPECTED that a new entry in the sqlth_te table be created. This will have a created date of your storeTagHistory() t_stamp, and a retired date of the created time of the original historian entry.

This was my initial thought, which was why I thought updating one of the te entries to a created t_stamp of 0 would solve the problem.

It turns out that I was correct, and if you are going to be storing history on tags from before they were actually created in the system, you can set the original tag created time to zero. After updating this sqlth_te created t_stamp to zero (or whatever earliest past date you will be using) you have to restart the Tag Historian.
This can be accomplished by restarting the entire gateway or changing something on the Historian Provider and applying the changes. I simply changed the description on the webpage and hit save changes, checked the log to confirm that it restarted the historian, and commenced testing my points. After this process, storeTagHistory() hasn’t created any additional sqlth_te entries.

The Caching is mentioned in the storeTagHistory() documentation, but I didn’t find it particularly clear and I certainly didn’t understand what I needed to do in order to use it properly.
https://docs.inductiveautomation.com/display/DOC79/system.tag.storeTagHistory

I hope this helps someone in the future (if so please like it so I know my time wasn’t wasted in posting the update / solution)

And big thanks to the support team.

-Rob W.

8 Likes