How to save Tag Values to SQL on Datachange

Hi Working with PlantScada 2020 R2, Am using the Tagsubscribe function to save tag values to a SQL table, but how do:

- Setup the call back to occur on datachange?

- Same request for setting up trend history files, want to set certaint ags to log on any datachange not based on a single deadband

  • It is possible to achieve.

    Part I

    • Use TagSubscribe Cicode function to subscribe a tag
    • Attach a callback Cicode function (follow the example on the help document)
    • The callback function will capture VQT of the tag
    • Pass the tag name and its VQT to your own Cicode function calling SQLCreate, SQLOpen... to insert the values. This will also depend on your schemes defined in SQL. For normalized tables (e,g, Tag name and Value tables), you may have to read Id of the tag before inserting the value to the value table

    Part ||

    • Define an event trend in your project
    • Use the same approach in Part I
    • In your callback Cicode function, use TrnSetTable for logging the value. Refer to the help document for details.

    Keep in mind that any SQL related functions should not be executed in any server process.

    Hope this would help.

  • In spite of your recommendation, I find using the Report Server process for these tasks very useful. This is normally not a client side task, so the Report Server process might be the best alternative. After all, it is a form of reporting that is done here.