After you have enabled the custom logic policies, you can use the sample
application. The following steps involve the use of several DB2
Everyplace applications and tools:
Procedure
The file paths used in this example are Windows specific and the variable
%DSYINSTDIR% is the directory where DB2 Everyplace is
installed. For UNIX, replace %DSYINSTDIR% with
$DSYINSTDIR.
- Use IBM Sync to refresh the initial data on your device (user=nurse1,
password=nurse1)
- Use DB2eCLP to view the data in your VNMEDICALRECORD table. The
schema of this table is:
- RecordID integer primary key
- Date_C date
- Time_C time
- PatientID char(9) NOT NULL
- BloodPressure char(7)
- PulseRate smallint
- Temperature decimal(4,1)
- Weight decimal(5,2)
- Comment varchar(100)
- Use DB2eCLP to insert a medical record
- CLP:> insert into vnmedicalrecord values (1000, current
date, current time, '900000001', '140/85', 80,
100.01, 145.50, 'CL statistic');
- Use IBM Sync to synchronize the vnmedicalrecord medical records
with the data source
- During synchronization, DB2 Everyplace custom logic writes the log
messages to STDOUT if you are using BeforeTableSyncIn,
TableSyncIn and AfterTableSyncIn policies. STDOUT
is recorded in the file
%DSYINSTDIR%\Server\logs\DB2eServer\native_stdout.log
(search for the strings "TableSyncInPolicy", "BeforeTableSyncInPolicy",
"AfterTableSyncInPolicy").
- Replication occurs periodically every 60 seconds. During
replication, custom logic writes the log messages to STDOUT if you are using
Before Database Replicate, Before Table Replicate,
Table Replicate, After Table Replicate and After
Database Replicate policies.
- Use DB2eCLP to insert a medical record
- CLP:> insert into vnmedicalrecord values (-1001, current date,
current time, '900000001', '140/85', 80, 100.01,
145.50, 'CL primary key change');
- Use DB2eCLP to review this newly created record. Note the primary
key value is -1001.
- Use IBM Sync to synchronize this medical record with the data
source. Several operations take place:
- To see how you can use custom logic for conflict resolution, you must
change periodic replication to replication on demand:
- Start the Mobile Devices Administration Center.
- Edit the Visiting Nurse subscription (JDBCSUB1)
- In the Advanced Replication Subscription, select Define
subscription and then Timing. Change 60 to
0.
- Insert a medical record in the VNURSE data source as follows:
- insert into dsysample.vnmedicalrecord (1002, current
date, current time, '900000001', '140/85', 80,
100.01, 145.50, 'CL conflict source data');
- Use DB2eCLP to insert a medical record
- CLP:> insert into vnmedicalrecord values (1002, current
date, current time, '900000001', '140/85', 80,
100.01, 145.50, 'CL conflict resolution -
winner').
- Use IBM Sync to synchronize this medical record with the data
source.
- Perform a manual replication
- Use IBM Sync to synchronize against the result of the conflict
resolution.
- Since both source and device inserted a conflicting record (with the same
primary key 1002), the Custom Logic policy resolves the conflict by selecting
the winner from the device "nurse1". This overrided the default
conflict resolution algorithm which always selects the record from the data
source as the winner. Here is the reference to the sample Custom Logic
which performs this conflict resolution.
- On the device, use DB2eCLP to see that the winner is the record inserted
from the device
- On the source, verify that the winner is the record inserted from the
device.
Související úlohy
Related concepts