j5 Wonderware Historian interface uses an ODBC SQL connection to communicate with the historian. The same connection can be used from an IndustraForm to execute a custom SQL query using the IMPORT.SQL function.
Use SQL queries to retrieve data from a Wonderware Historian database table in an IndustraForm
Using data-binding on an IndustraForm section and the IMPORT.SQL formula, a SQL query can be used to query Wonderware Historian tables. (This assumes that the user configured to access the database has the appropriate statement execution permissions.)
The following is an example of a data-binding that retrieves information from the History table for the tag "SysPerfCPUTotal" between the two dates passed in as parameters.
= IMPORT.SQL("ww_historian", "SELECT DateTime, TagName, Value FROM Runtime.dbo.History WHERE TagName = ? and DateTime >=? and DateTime <=? and wwTimezone = ?", "SysPerfCPUTotal", "2018-04-09", "2018-04-10", "UTC")
This information can then be displayed by making use of the BOUNDCOL function where each column of data to be displayed needs its own BOUNDCOL statement referencing the name of the column as a parameter.
When this is done, the correct number of rows will automatically be displayed depending on how many rows are returned from the query.
For more information about data-binding and the IMPORT.SQL formula, refer to IndustraForm Data Wizardry.
Use stored procedures to retrieve data from a Wonderware Historian database table in an IndustraForm
It is possible to make use of stored procedures from a Wonderware Historian database within an IndustraForm.
As with retrieving table data, this can be done by making of use the IMPORT.SQL function.
The example below demonstrates an example of using Wonderware’s wwAnalogDetail Stored Procedure which returns information about one or more analog tags passed in as a parameter.
= IMPORT.SQL("ww_historian", "EXEC wwAnalogDetail ?", "SysPerfCPUTotal")
For more information about different stored procedures available in Wonderware Historian, refer to the Stored Procedure section (Chapter 4) in the Wonderware Historian Database Reference.