REFRESH CACHE GROUP
The REFRESH CACHE GROUP statement replaces data in the TimesTen cache tables with the most current committed data from the Oracle database cached tables.
                  
Required Privilege
CREATE SESSION on the Oracle Database schema and SELECT on the Oracle Database tables.
                  
No privilege for the cache group is required for the cache group owner.
REFRESH or REFRESH ANY CACHE GROUP for another user's cache group.
                  
INSERT, DELETE, UPDATE privileges on underlying tables.
                  
Usage with TimesTen Scaleout
This statement is supported with TimesTen Scaleout.
SQL Syntax
REFRESH CACHE GROUP [Owner.]GroupName [WHERE ConditionalExpression] COMMIT EVERY n ROWS [PARALLEL NumThreads]
or
REFRESH CACHE GROUP [Owner.]GroupName WITH ID (ColumnValueList)
Note:
TheWITH ID clause is not supported in TimesTen Scaleout.
                  Parameters
| Parameter | Description | 
|---|---|
| 
 | Name assigned to the cache group. | 
| 
 | Use the  | 
| 
 | Use the  
 | 
| 
 | Provides parallel loading for cache group tables. Specifies the number of loading threads to run concurrently. One thread performs the bulk fetch from the Oracle database and the other threads ( The minimum value for  | 
| 
 | The  The  | 
Description
- 
                        A REFRESH CACHE GROUPstatement must be executed in its own transaction.
- 
                        Before issuing the REFRESH CACHE GROUPstatement, ensure that the replication agent is running if the cache group is replicated or is an AWT cache group. Make sure the cache agent is running.
- 
                        The REFRESHCACHEGROUPstatement replaces data in the TimesTen cached tables with the most current committed data from the cached Oracle database tables, including data that already exists in the TimesTen cached tables. For an explicitly loaded cache group, a refresh operation is equivalent to issuing anUNLOAD CACHE GROUPstatement followed by aLOAD CACHE GROUPstatement. Operations on all rows in the Oracle database tables including inserts, updates, and deletes are applied to the cache tables. For dynamic cache groups, a refresh operation refreshes only rows that are updated or deleted on the Oracle database tables into the cache tables. For more information on explicitly loaded and dynamic cache groups, see Transmitting Changes Between the TimesTen and Oracle Databases in Oracle TimesTen In-Memory Database Cache Guide.
- 
                        When refreshing a read-only cache group: - 
                              The AUTOREFRESHstate must be paused.
- 
                              If the cache group is a read-only dynamic cache group, do not use the PARALLELclause.
 
- 
                              
- 
                        If the automatic refresh state of a cache group (dynamic or explicitly loaded) is PAUSED, the state is changed toONafter an unconditionalREFRESH CACHE GROUPstatement issued on the cache group completes.
- 
                        If the automatic refresh state of a dynamic cache group is PAUSED, the state remainsPAUSEDafter aREFRESH CACHE GROUP...WITH IDstatement completes.
- 
                        Generally, you do not have to fully qualify the column names in the WHEREclause of theREFRESH CACHE GROUPstatement. However, since TimesTen automatically generates queries that join multiple tables in the same cache group, a column must be fully qualified if there is more than one table in the cache group that contains columns with the same name.
- 
                        If the REFRESH CACHE GROUPstatement fails when you specifyCOMMIT EVERYnROWS(wheren>= 0), the content of the target cache group could be in an inconsistent state since some loaded rows are already committed. Some cache instances may be partially loaded. Use theUNLOAD CACHE GROUPstatement to unload the cache group, then use theLOAD CACHE GROUPstatement to reload the cache group.
- 
                        Following the execution of a REFRESH CACHE GROUPstatement, the ODBC functionSQLRowCount(), the JDBC methodgetUpdateCount(), and the OCI functionOCIAttrGet()with theOCI_ATTR_ROW_COUNTargument return the number of cache instances that were refreshed.
- 
                        Use the WITH IDclause:- 
                              In place of the WHEREclause for faster refreshing of the cache instance
- 
                              To specify binding parameters 
- 
                              To roll back the refresh transaction upon failure 
 
- 
                              
Restrictions
- 
                        The REFRESHCACHEGROUP...WITHIDclause is not supported in TimesTen Scaleout.
- 
                        Do not specify the PARALLELclause:- 
                              With the WITH IDclause
- 
                              With the COMMITEVERYnROWSclause
- 
                              When database level locking is enabled (connection attribute LockLevelis set to 1)
- 
                              For read-only dynamic cache groups 
 
- 
                              
- 
                        Do not use the WITH IDclause when refreshing these types of cache groups:- 
                              Static read-only cache groups 
- 
                              Static user managed cache groups with the autorefresh attribute 
- 
                              User managed cache groups with the autorefresh and propagate attributes 
 
- 
                              
- 
                        Do not use the WITH IDclause with theCOMMIT EVERYnROWSclause.
- 
                        Do not use the WHEREclause with dynamic or read-only cache groups.
Examples
REFRESH CACHE GROUP recreation.cache COMMIT EVERY 30 ROWS;
Is equivalent to:
UNLOAD CACHE GROUP recreation.cache; LOAD CACHE GROUP recreation.cache COMMIT EVERY 30 ROWS;
Use the HR schema to illustrate the use of the PARALLEL clause with the REFRESH CACHE GROUP statement. The COMMIT EVERY n ROWS is required. Issue the CACHEGROUPS command. You see cache group cg2 is defined and the autorefresh state is paused. Specify the REFRESH CACHE GROUP statement with the PARALLEL clause to provide parallel loading. You see 25 cache instances refreshed.
                  
Command> CACHEGROUPS; Cache Group SAMPLEUSER.CG2: Cache Group Type: Read Only Autorefresh: Yes Autorefresh Mode: Incremental Autorefresh State: Paused Autorefresh Interval: 1.5 Minutes Root Table: SAMPLEUSER.COUNTRIES Table Type: Read Only Child Table: SAMPLEUSER.LOCATIONS Table Type: Read Only Child Table: SAMPLEUSER.DEPARTMENTS Table Type: Read Only 1 cache group found. Command> REFRESH CACHE GROUP cg2 COMMIT EVERY 20 ROWS PARALLEL 2; 25 cache instances affected.