The INSERT command adds data from iFIX tags into a new row in the relational database. INSERT statements can have only one record associated with them.
SQT1 – the SQL Trigger block defines the SQL name and command to use. In this example, the following INSERT command in the SQLLIB table executes when the SQT block triggers:
Insert into TBL1 (COL1, COL2, COL3) values (?, ?, ?);
SQD1 – the SQL Data block references three tag and field name combinations in the database, and sets the direction for the data transfer to OUT.
T01-. AI1.A_DESC
T02-. AO1.F_CV
T03-. DO1.A_ADI
TBL1 – is the table referenced by the INSERT command that is used in the SQT block.
COL1 |
COL2 |
COL3 |
Pump stage 101 |
99.7 |
Hello |
Temp Zone 2 (C) |
-2.1 |
ByeBye |
Manual Override |
.004 |
what |
Explanation
When the software executes this INSERT command, it creates a new row in TBL1 that contains the values of the iFIX tags and field names listed in the SQD1 block. The resulting table is shown below:
COL1 |
COL2 |
COL3 |
Pump stage 101 |
99.7 |
Hello |
Temp Zone 2 (C) |
-2.1 |
ByeBye |
Manual Override |
.004 |
what |
AI1 Descriptor fld |
21.04 |
ABDFG |
AI1 Descriptor fld – comes from the AI1 block's A_DESC.
21.04 – comes from the AO1 block's F_CV.
ABDFG – comes from the DO1 block using the A_ADI field.
NOTE: If the SQL task cannot read a value from a block (for example, it attempts to read the current value of an Analog Input block while the block is off scan), the SQL task substitutes a null value in place of the block value. If the target column does not accept null values, a new row is not inserted and the SQL task generates an error. The SQT block also generates an alarm.