The chained operation cache update policy allows you to chain a read operation to create, update, or delete operations, and update the consolidated database (CDB) at a finer granularity.
The chained operation cache policy allows chaining of an alternate read operation to a create, update, or delete (CUD) operation. The parameters of the alternate read operation should be a subset of the parameters of the chaining operation. The parameter values of the chaining operation are passed to the alternate read operation and the results returned from the alternate read operation are then applied to the CDB.
Note: These terms all represent the same thing: consolidated database, CDB, and cache.
This example uses the department table, which is in the sampledb database:
- Drag and drop the department table onto the Mobile Application Diagram to create a mobile business object (MBO).
- In the MBO, double-click the Create operation to open the Operation Properties dialog.
- Select the Cache Policy tab, and select Chained operation.
- Select New to launch the Mobile Business Operation Creation wizard, and define the chained operation:
- Name – ChainedRead.
- Operation type – Read.
- Connection type – Database.
- Connection name – select a connection to the sampledb database.
- Define the SQL query – select * from department where dept_id < 400.
- Click Finish.
- Deploy the MBO to Unwired Server.
The result is an MBO that when accessed from a device application or test client behaves as follows (assuming the MBO's
Cache interval is sufficiently long to complete the test without requiring a cache refresh):
- The create operation inserts records into the sampledb database.
- The read operation is called after the create operation, and updates the CDB with records where dept_id < 400.
From an end-to-end perspective:
- Initially, synchronizing this MBO from a test client or a device application results in the
client, CDB, and EIS with the same data:
dept_id dept_name dept_head_id
------- ----------- ------------
100 R & D 501
200 Sales 902
300 Finance 1293
400 Marketing 1576
500 Shipping 703
- This record is inserted into the EIS (using some method other than the MBO operation):
dept_id=1000, dept_name="QA", dept_head_id=501
The EIS now contains:dept_id dept_name dept_head_id
------- ----------- ------------
100 R & D 501
200 Sales 902
300 Finance 1293
400 Marketing 1576
500 Shipping 703
1000 QA 501
Neither the client nor the CDB are updated with the new record.
- The client invokes the create operation to insert the record:
dept_id=350, dept_name="QA", dept_head_id=501
- The chained read operation is invoked.
- The client synchronizes the MBO. While the EIS contains dept_id=1000 and dept_id=350:
dept_id dept_name dept_head_id
------- ----------- ------------
100 R & D 501
200 Sales 902
300 Finance 1293
400 Marketing 1576
500 Shipping 703
1000 QA 501
350 QA 501
Based on the read operation's definition, the only new record retrieved from the EIS and updated in the CDB and the client is the dept_id=350 record: dept_id dept_name dept_head_id
------- ----------- ------------
100 R & D 501
200 Sales 902
300 Finance 1293
400 Marketing 1576
500 Shipping 703
350 QA 501