Chained Operation Cache Policy

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:
  1. Drag and drop the department table onto the Mobile Application Diagram to create a mobile business object (MBO).
  2. In the MBO, double-click the Create operation to open the Operation Properties dialog.
  3. Select the Cache Policy tab, and select Chained operation.
  4. 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.
  5. 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):
  1. The create operation inserts records into the sampledb database.
  2. 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:
  1. 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 
  2. 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.

  3. The client invokes the create operation to insert the record:
    dept_id=350, dept_name="QA", dept_head_id=501 
  4. The chained read operation is invoked.
  5. 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