queryTagHistory

I am attempting to grab a DataSet from an historical tag. I am using the system.tag.queryTagHistory() method to do this. I am using this script in a project that has the default database set to “A”, but the historical tag is being stored in database “B”. When I use the system.tag.queryTagHistory() method it attempts to look up the history in the database “A” instead of database “B”, even though the historical tag is setup to store in database “B” using the historical tag setup in the edit tags dialog. Is there a way of setting the target database for this method?

ERROR:
Traceback (innermost last):
File “event:actionPerformed”, line 16, in ?
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 500: Table ‘A.sqlth_drv’ doesn’t exist
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table ‘A.sqlth_drv’ doesn’t exist
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 500: Table ‘A.sqlth_drv’ doesn’t exist

Ignition v7.2.5 (b76)
Java: Sun Microsystems Inc. 1.6.0_24

I think I figured it out. The tagPath uses the database name in brackets, which wasn’t very intuitive to me since generally the tag path is related to the OPCUA driver. Anyway, it works now using the tagPath ["[B]folder/tag"]

Yes, tag paths come in different forms, and in the case of SQLTags history, it’s in the form “[historyprovider]path/to/tag”, where right now “historyprovider” is the name of the database.

It can actually even be a bit more complex, as you could have multiple Ignitions logging data to the same database. If you had the same tag structure, you would need to distinguish the tags with the “system name”, which you could do with a path like:
“[provider/systemname]path/to/tag”

You won’t have to worry about that for your example, but I just wanted to mention it.

Regards,