Applies to:
PcVue 15.1 onwards |
||||||||||||
|
||||||||||||
Summary:
PcVue 15 introduces the possibility to create Sql variables based on Sql queries. Version 15.1 introduces the ability to manually trigger these queries by manually entering parameter values. This article proposes a use case of these mechanisms. The repeat query option triggers automatically a query when the number of records received is greater than or equal to a constant value, instead of waiting for the configured trigger. Ex: Data avalanche or restart of PcVue after a downtime. |
||||||||||||
|
||||||||||||
Details:
We have a query execution defined to be repeated every 10 seconds and with a maximum received row count equal to 100: Then in the query itself, we add conditions according our execution plan. We want to retrieve the last 100 values since the last retrieved value: About the query:
TrendTable1: Name of the table In the WHERE condition, we use dynamic parameters and we store them in PcVue Sql variables:
Creation of these variables:
The attached sample project shows an example of using SQL queries attached to SQL connections defined in PcVue. In particular, it shows a possibility to repeat the execution of these queries automatically under certain conditions. First of all, you need to enter the correct login and password for the SQL connection declared in the general part of the Application Explorer: The query will be launched every 10 seconds. It will retrieve all the information from the TRENDTABLE1 table by packets of 100 rows, starting from the last information retrieved previously. After the development of such a query, it is mandatory to run it at least once by manually entering the parameters. For instance if we want to get all data: Then, since we save the value of the internal variables that are used both to define the parameters of the query and to store their new value after each execution, the system works continuously. If we look at the trend curve, we can see that the variable SQL.Query01.F1R1_TEMP only changes value every 10 seconds, at the rate of the SQL query. But in fact it changes value several times and all these changes are recorded with the timestamp coming from the TRENDTABLE1 table. So when we press the refresh button, we see a nice smooth ramp instead of stairs in real time. |
||||||||||||
|
||||||||||||
Sample project: |
||||||||||||
|
||||||||||||
|
Created on: 28 Jan 2021 Last update: 30 May 2024