2 Replies Latest reply on Nov 10, 2016 8:39 AM by esancha

    How can I get sampled data from a digital tag with PIOLEDB




      I'm trying to get sampled data from PI with PIOLEDB through the next query

      SELECT Time, Value FROM piarchive..piinterp2 WHERE tag = 'FFH:B_002' AND time BETWEEN 't' and '*' and the result its a numeric value not related the digital state of the tag (-2293772)

      Some messages from this forum talk about using name, but if I use it, an error occurs: "Column name 'name' is invalid."


      How can I obtain this data?


      Thank you.

      Regards, Emilio Sancha

        • Re: How can I get sampled data from a digital tag with PIOLEDB
          Asle Frantzen



          By sampled data I expect you mean archived data, which in PI terms is referred to as compressed data. For that you need to query the picomp/picomp2 "tables". The following example will return all the archived events between midnight and now:


          SELECT tag, time, DIGSTRING(status) value
          FROM piarchive..picomp 
          WHERE tag = 'cdm158' 
          AND time >= 't'


          If you mean sampled as in time-stepped data (every hour) you need to use the piinterp/piinterp2 "tables". This example will return values with 1 hour timestep, from yesterday (midnight) to today (midnight):


          SELECT tag, time, DIGSTRING(status)
          FROM piarchive..piinterp
          WHERE tag = 'cdm158' 
          AND time BETWEEN 'y' AND 't' 
          AND timestep = '1h'


          Use the picomp/piinterp-tables as shown if you want to output the actual digital states as text. For the picomp2/piinterp2-tables the status field will show the quality of data, and the actual value is found in the value field.

          1 of 1 people found this helpful