解析MobiLink实现基于时间戳的分区同步

豆豆网   技术应用频道   2007年08月06日  【字号: 收藏本文

内容摘要:解析MobiLink实现基于时间戳的分区同步

  一 建库及数据源

  1.建立数据库

  在cmd下执行,中央数据库consol

D:mobilink>dbinit consol

  两个远程数据库zhou1 zhou2

D:mobilink>dbinit zhou1
D:mobilink>dbinit zhou2

  2.启动服务

  在命令行下敲dbsrv9,在弹出的对话框中选择数据库文件,并敲入相应的服务名, 按照这种方式启动consol zhou1 zhou2 服务。

  3.建立odbc数据源

consol zhou1 zhou2

  二 处理中央数据库

  1.dbisql 连接到consol数据库

  执行以下语句:

  -- 建表,owner列作为分区用, active 用作逻辑删除 last_modified 用作时间戳同步,只在中央数据库需要这三列,远程数据库不需要。

create table employee(id int NOT NULL PRIMARY KEY,
name varchar(128),
owner varchar(128),
active int default 1, last_modified
timestamp DEFAULT timestamp)
-- 录入数据   
insertinto employee(id, name, owner,
active ) values (1, '小桥', 'zhou1', 1)
insert into employee(id, name, owner,
active ) values (2, '流水', 'zhou2', 1)
insert into employee(id, name, owner,
active ) values (3, '人家', 'zhou1', 1)
commit
go
-- 加入脚本版本及脚本
 call ml_add_table_script( 'version1',
'employee', 'upload_insert', 'insert into
employee(id, name) values (?,?)' )
 go
 call ml_add_table_script( 'version1',
'employee', 'upload_update', 'update employee
set name=? where id = ?' )
 go
 call ml_add_table_script( 'version1',
'employee', 'upload_delete', 'delete from
employee where id = ?' )
 go
 call ml_add_table_script( 'version1',
'employee', 'download_cursor','select id,
name from employee where last_modified > ?
and owner = ? and active = 1' )
 go
 call ml_add_table_script( 'version1',
'employee', 'download_delete_cursor',
'select id from employee where last_modified>?
and (owner !=? or active = 0)' )
 go

责编:豆豆技术应用

正在加载评论...