36 High-Function Business Intelligence in e-business
Consider, for example, that you have an materialized view that has data grouped
by month. Assume that the data was up to and including the month of June. If a
sales entry is made for the month of June, the delta change to the aggregation is
computed so that the row in the materialized query table is updated to reflect the
newly inserted row in the base sales table. If a row is inserted into the sales table
for the month of July, a new row would be inserted in the materialized view since
one did not exist before for July.
When a LOAD INSERT operation is performed on the base table(s) of a
materialized view, the newly appended data is invisible for read access, thus
ensuring that the base table(s) and corresponding materialized views are still in
sync.
In order to make the appended data visible and synchronized with the
materialized view, perform the following steps:
1. Issue the following statement against the base table:
SET INTEGRITY FOR base_table_name IMMEDIATE CHECKED
This statement will make the base table available after verifying the
consistency of the newly appended rows to the base table. It will also cause a
CHECK PENDING NO ACCESS state to be set on the materialized view.
2. Issue a SET INTEGRITY or REFRESH TABLE of the materialized view with
the INCREMENTAL option to bring the materialized view in sync with all the
rows added by the LOAD INSERT operation.
See “Loading base tables (LOAD utility)” on page 37 for some of the options
available when loading data into a base table.
Immediate refresh considerations
Two main considerations apply here as follows:
? REFRESH IMMEDIATE materialized views require updates to the underlying
base table(s) to be reflected within the same unit of work. This atomic
requirement can have a significant negative impact on transactions updating
the base table(s). You should carefully evaluate the business requirements of
Note: DB2 may use pipelining or temporary tables to effect this operation.
Attention: Since this entire operation is atomic, any error encountered while
updating either the base table or the materialized view will roll back all the
changes during the unit of work. This guarantees the synchronization of the
materialized view with the base tables.