Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91766381
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Sybase

2008-04-10 20:53:33

  来源:赛迪网    作者:Sybase

一 建库及数据源

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

-- 注意go 前面不要有空格。为了保持格式,这里是有空格的,执行时要注意。

阅读(430) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~