SELECT {index} FROM {table}
WHERE t_stamp::date = {[.]date}::date
AND nom_produit = {[.]nom_produit}
ORDER BY {index} DESC
LIMIT 1
Where {index}, {table} are string type parameters and {[.]date}, {[.]nom_produit} are internal UDT tags.
It’s returning: ‘Error expression eval’ on Ignition 8.1
How can achieve that in the new version?
Hello all,
I am following the example to understand how to do something similar.
In my case i have a SQL list of stations, and UDT list, were the nimber of the station correspond to the ID of the station.
(SQL)1 , North station → Station 1 (UDT)
Amd i am traying to get the value [default]Stations/Station 1/State tag (int)
Right now I don’t Know how what is the name of stations database, i think is the SQL data
Firstly, you can’t use dynamic parameters in the query browser, so you’ll need to replace all of those {} references with static values.
All of the historised tags are stored in the sqlth_te table which you’ll need to use to lookup the id of the tag you’re wanting to pull the data for and use that id in the WHERE clause of the SELECT.
e.g.
SELECT * FROM sqlt_data_1_2021_01 WHERE id = 12
you could also do the lookup directly in the SQL:
SELECT * FROM sqlt_data_1_2021_01 WHERE id =
(SELECT TOP 1 id FROM sqlth_te WHERE tagPath = 'path/to/tag')
Not sure if “tagPath” is correct, need to check the name
If you’re still having an issue as in your deleted post, the [ and ] are special characters in sql and you either need to 1. remove them, and I can’t remember if the tag provider is stored with the tagpath or not, or 2. escape them using [[]
SELECT vvalue
FROM HISTORY
WHERE TagName = {TAGNAME}
AND wwVersion = ‘Latest’
AND DateTime = {DATETIME}
Can we add the parameter in the SQL query on the UDT? This is not working on my version…If I need to create an external expression can you provide a link?