Inserting data into an application-period temporal table
Inserting data into an application-period temporal table is similar to inserting data into a regular table.
About this task
Procedure
To insert data into an application-period temporal table,
use the INSERT statement to add data to the table.
For
example, the following data was inserted to the table created in the
example in Creating an application-period temporal table topic.
INSERT INTO policy_info VALUES('A123',12000,'2008-01-01','2008-07-01');
INSERT INTO policy_info VALUES('A123',16000,'2008-07-01','2009-01-01');
INSERT INTO policy_info VALUES('A123',16000,'2008-06-01','2008-08-01');
INSERT INTO policy_info VALUES('B345',18000,'2008-01-01','2009-01-01');
INSERT INTO policy_info VALUES('C567',20000,'2008-01-01','2009-01-01');
Results
- The second insert adds a row for
policy_id
A123 with abus_start
value of 2008-07-01 and abus_end
value of 2009-01-01. - The third insert attempts to add a row for
policy_id
A123, but it fails because its BUSINESS_TIME period overlaps that of the previous insert. Thepolicy_info
table was created with a BUSINESS_TIME WITHOUT OVERLAPS index and the third insert has abus_end
value of 2008-08-01, which is within the time period of the earlier insert.
bus_end
value
of 2008-07-01 does not have a BUSINESS_TIME period overlap with the
row that contains a bus_start
value of 2008-07-01.
As a result, the policy_info
table now contains the
following insurance coverage data:
policy_id | coverage | bus_start | bus_end |
---|---|---|---|
A123 | 12000 | 2008-01-01 | 2008-07-01 |
A123 | 16000 | 2008-07-01 | 2009-01-01 |
B345 | 18000 | 2008-01-01 | 2009-01-01 |
C567 | 20000 | 2008-01-01 | 2009-01-01 |