how to change retrieval mode with SQL in Archive..picomp2 Table to get previous compressed time value?
I can´t use a time interval.
I´m using a PI OLEDB Provider.
Are you looking to get the last compressed value before the current snapshot, or the current snapshot?
If you want the last compressed value (= snapshot), you can query the snapshot table directly. E.g.
SELECT * FROM [piarchive].[pisnapshot] WHERE tag = 'cdt158'
If you want to retrieve the value before that, PI OLEDB supports most PI Performance Equations syntax. E.g.
SELECT PrevVal('cdt158', PrevEvent('cdt158', '*+1s'))
will give you the last compressed value before the current snapshot.
Note that every cell in the result set using the PE functions will require a server round-trip. So this query might not be ideal if you are looking to retrieve many tag values with this method. If so, you can potentially make sure of the TOP syntax to only retrieve 2 values from the picomp2 table, looking backward in time (starting from current time).
Thank u So Much.
select top 1 * from (
SELECT top 2 *
WHERE tag = 'sinusoid'
order by time desc) a
order by time asc
I gave an example above using sinusoid.
Retrieving data ...