SQLUpdate() function
- Last UpdatedJun 17, 2024
- 1 minute read
The SQLUpdate() function uses the current values of InTouch tags to update all rows in a table that match the condition set by the WhereExpr argument.
Category
SQL
Syntax
[ResultCode=]SQLUpdate(ConnectionID, TableName, BindList, WhereExpr);
Arguments
ConnectionID
Name of a memory integer tag that holds the number (ID) assigned by the SQLConnect() function to each database connection.
TableName
The name of the database table to access.
BindList
Defines which InTouch tags are used and which database columns they are associated with.
WhereExpr
Defines a condition that can be either true or false for any row of the table. The function updates only those rows from the table for which the condition is true. The expression must be in the following format:
ColumnName comparison_operator expression.
Note: If the column is a character data type, the expression must be in single quotes.
Example
The following example selects all rows whose name column contains the value EmployeeID:
name='EmployeeID'
The following example selects all rows containing part numbers from 100 to 199:
partno>=100 and partno<200
The following example selects all rows whose temperature column contains a value that is greater than 350:
temperature>350
The following statement updates all records in the table BATCH, whose lot number is 65, to the current values of the tags specified in the BindList "List1":
ResultCode=SQLUpdate(ConnectionID,"BATCH", "List1","lotno=65");
Note: Be sure that all records are unique. If identical records exist in a table, all similar records are updated.
See Also
SQLConnect()