There are two ways to insert new records in a database in addition to using native E3 objects: via a Query or via scripts.
If record insertion is performed via Query, you must configure the SQL code of the Query this way:
INSERT INTO Table1 (Batch, Batch_Quality, User, User_Quality, E3TimeStamp)
VALUES ('<%Batch%>', 192, '<%User%>', 192, #<%StartDate%>#)
NOTE: This SQL configuration is valid for any database.
In case record insertion is performed via script, the command to use is WriteRecord. This type of script can be configured to insert records manually, via a button script, or automatically, when a property changes its value.
In the configuration of a Historic with manual recording, you must configure the recording time for new records with zero and, after that, develop a script using the WriteRecord method on a button or on a property. The following example shows a script on a button.
Figure 1: Script used in a button
Exercise
-
Create a button with a script using the WriteRecord method.
-
Insert an E3Browser on the Screen, link it to the Historic previously created and configure it to update itself every 1000 ms.
-
Check whether the value was recorded.