SQLAppend
- Last UpdatedNov 17, 2021
- 1 minute read
The SQLAppend method appends a section of a long SQL statement to the end of the existing SQL string in the SQLString property.
Syntax
[Result=] aaHistClientActiveDataGrid.SQLAppend(message SQL);
Parameters
SQL
Section of SQL to be added to the SQL statement(s) that are to be executed.
Remarks
This method facilitates the scripting of long SQL Statements within the InTouch HMI software. Currently, the InTouch HMI software has a 131 character limitation for strings. To circumvent this limitation, use this method to add SQL statements in sections.
Example
The following example demonstrates how to use the SQLAppend method to setup the necessary SQL to retrieve the last 30 minutes of history data for the tag 'SysTimeSec.'
#aaHistClientActiveDataGrid.ServerName = "toddm1";
#aaHistClientActiveDataGrid.UserName = "wwUser";
#aaHistClientActiveDataGrid.Password = "wwUser";
#aaHistClientActiveDataGrid.SQLString = "";
#aaHistClientActiveDataGrid.SQLAppend("DECLARE @StartDate Datetime");
#aaHistClientActiveDataGrid.SQLAppend("DECLARE @EndDate Datetime");
#aaHistClientActiveDataGrid.SQLAppend("SELECT @StartDate = DateAdd(mi, -30, GetDate())");
#aaHistClientActiveDataGrid.SQLAppend("SELECT @EndDate = GetDate()");
#aaHistClientActiveDataGrid.SQLAppend("SELECT TagName, DateTime, Value");
#aaHistClientActiveDataGrid.SQLAppend("FROM v_AnalogHistory");
#aaHistClientActiveDataGrid.SQLAppend("WHERE TagName IN ('SysTimeMin')");
#aaHistClientActiveDataGrid.SQLAppend("AND DateTime >= @StartDate");
#aaHistClientActiveDataGrid.SQLAppend("AND DateTime <= @EndDate");
#aaHistClientActiveDataGrid.SQLAppend("AND wwRetrievalMode = 'Delta' ");
#aaHistClientActiveDataGrid.Execute();