Translations:ViewPLUS Editor/54/en

From Mikrodev Documentation
Jump to navigation Jump to search
  • Query : The query expression to be executed in the database. This tag allows retrieving the first line returned from the query. The return values ??for this first row are written into tags respectively into the tags defined in the form of :{${32}, ${33} , ${34}, ${35},....}:

An example "Query" expression:

WITH
t1 AS (
  SELECT  data_value from logs.tag_log  l where tag_id=19 AND data_value IS NOT NULL ORDER BY logtime DESC limit 1 ),
t2 AS (
  SELECT  data_value from logs.tag_log  l where tag_id=20 AND data_value IS NOT NULL ORDER BY logtime DESC limit 1),
t3 AS (
  SELECT  data_value from logs.tag_log  l where tag_id=29 AND data_value IS NOT NULL ORDER BY logtime DESC limit 1),
t4 AS (
  SELECT  data_value from logs.tag_log  l where tag_id=26 AND data_value IS NOT NULL ORDER BY logtime DESC limit 1)
 
SELECT t1.data_value data1, t2.data_value  data2, t3.data_value  data3, t4.data_value  data4
 FROM t1, t2 ,t3,t4;

:{${32}, ${33} , ${34}, ${35}}:

In the above PostgreSQL database query, the latest recorded database values of the tags 19, 20, 29, and 26 ??are written into the tags with 32, 33, 34, 35 IDs, respectively.