I am trying to configure my PI tag to be able to read data from an sql database.
the query works well and I just want to fecth the latest Cd_mean value. how can I configure my PI tag to store that value in a PI tag
I am trying to configure my PI tag to be able to read data from an sql database.
the query works well and I just want to fecth the latest Cd_mean value. how can I configure my PI tag to store that value in a PI tag
Setting Location2 to 0 (process only the first row) should do the work, as long as you can make sure the latest value always comes onto the 1st row.
Thank you Damian Nguyen what about if I want to select a specific colum(is that location 3 configuration?) . also can you please what location 4 and 5 are for.
I supposed what you meant by "Selecting specific column" is that you want to use a 'Group Distribution'. This means that your result table should look like [Time],[Value1],0,[Value2],0,etc. with 0s being separation columns. Have a look:
SELECT timestamp, temperature, 0, pressure, 0, level, 0
FROM table3
WHERE key1 LIKE 'Tank1' AND timestamp > ? ORDER BY timestamp ASC;
Location4 is for scan class and Location5 is for Exception Reporting (0 = enabled, 1 = disabled). Side note, you should also look into interface configurations like "Ignore Nulls" and "Read Before Overwrite", here's the user guide.
rbitcoin Location3 in Group Distribution is for assigning the corresponding Value column (usually even numbers as you can guess from the query above)
another option may be to change your SQL query to return a single row with the largest timestamp?
If you are only going to process that one anyway, it could be better for the network and other resources not to return a bunch of unuseful rows
Well this is only a suggestion and not meant to be a direct solution to rbitcoin's desire (although a slight change should do). I do agree with you that the query result should be as optimized and light-weighted as possible, but from personal experience getting SQL data from external applications, human errors and sometimes negligence can require data to be adjusted and thus, require overriding PI data.
sahilp I like this approach. I'm thinking that there will be 2 queries. 1 query to get results for distribution and 1 query to get the latest timestamp. The query to get the data will use the largest timestamp in the where clause to fetch the latest data. Is this possible to do this all in one query and then update the latest timestamp accordingly after?