Use an SQL Query to Insert or Update Data in Another Database
To update or insert a value into another database using ODBC data transfer methods, you need to send a point control to the other database. The point control executes an SQL statement that specifies the location at which the point value, and optionally the associated time stamp, are to be updated or inserted within the other database.
For a control to be sent to another database in this way:
- The other database has to support Write privileges.
- ClearSCADA has to have Write as well as Read access to the required location within the other database. You specify this access by entering a suitable User Name and Password on the associated ODBC Connection Form (see Configure the Connection Properties).
- The relevant ODBC point(s) need to be enabled for control in ClearSCADA. You can do this by using the Enabled check box on the Query tab of the corresponding ODBC Point Form.
- For an analog point, you need to specify the control range, using the fields on the Query tab of the corresponding ODBC Point Form (see Define the Query Properties).
- For a digital point, you need to enable and configure the required control action(s), using the fields on the Query tab of the corresponding ODBC Point Form (see Define the Query Properties).
- For any ODBC point type for which the control feature is enabled, you need to specify the SQL Query that the control is to execute. Enter the required code using the Query field on the Query tab of the corresponding ODBC Point Form.
Example:
An Oracle database includes the following database table:
Table Name: SCADADATA
ValueId |
Value |
Time |
---|---|---|
1 |
3.5 |
10:15 |
2 |
4.7 |
10:15 |
3 |
12.3 |
10:15 |
An ODBC Analog point is used to update the value and time stamp for the row where ValueId = 3. To do this, the analog point is configured to use this SQL query command on the Query tab of the OBDC Analog Point Form:
UPDATE SCADADATA SET Value=?, Time=? WHERE ValueID=3
At 10:26, an operator selects the Control pick action for the ODBC Analog point, and specifies a value of 10.4 in the Control window that is displayed. When the control is executed, the data in ValueId row 3 of the Oracle database is updated to display a value of 10.4 with a Time of 10:26.