Creating Tags

from https://docs.inductiveautomation.com/display/DOC80/Creating+Tags 


Creating Query Tags

Query Tags execute a SQL Query, whose result provides the value for the Tag. Like SQL binding in Vision, SQL Query Tags can reference other Tags to build dynamic queries. Query Tags cannot be written to. The value of a Query Tag comes from the database through a SQL query.

 Click here to create Query Tags...

Create a Query Tag

In this example, we'll create an query tag that selects the current timestamp.

  1. From Tag Browser, click on the New Tag  icon or right click on a folder and select New Standard Tag > Query Tag.
  2. In the Tag Editor, enter:

    Name: Current Time
    Data Type: DateTime
    Datasource: MySQL




  3. Next to the Query property, click on the Edit  icon.
  4. Copy in the following query:

    SELECT CURRENT_TIMESTAMP

    Query Type

    In certain circumstances you may want to update the database instead of querying it for data. The Query Tag will accept an update query and update the target data source. The value attribute of the Tag becomes the number of rows affected by the update query.

    The data source refers to the default data source of the Tag provider as opposed to the default data source of the project.

    In the Gateway Configure Section, go to Tags > Realtime and edit the appropriate Tag provider. Set the default database connection that this Tag provider will use for its Query Tags.

  5. Click Commit then click OK. You will see the value from your SQL query on the Current Time Tag.

留言

熱門文章