TBatchMove 批量移动数据
既然是移动,就有一个数据源Source,一个目的表Destination
Source可以是Table也可以是Query.
Destination我只用过Table,Query不敢肯定
移动方式,有copy,append,update等.选择copy方式很方便,不论目的表是否存在
都可以,如存在就覆盖,不存在就创建.也不用考虑目的表的结构.
以下是我曾经用过的一段代码:通过改变source,destination可以依次移动多批
数据.quy_sour:数据源.
Batchmove1: source:quy_sour
dest :tbl_dest(可以改变它的tablename属性)
mode :batcopy
with quy_sour do
begin
close;
sql.clear;
sql.add('select * from yppy where ylbm=:l and ypbm in
(select ypbm from yfkc where yfbm=:f)');
params[0].asstring:=xybm;
params[1].asstring:=xyf;
open;
tbl_dest.TableName:='yppy';
try
BatchMove1.Execute;
except
showmessage('无法更新');
end;
close;
sql.clear;
sql.add('select * from ypbm where ylbm=:l and ypbm in
(select ypbm from yfkc where yfbm=:f)');
params[0].asstring:=xybm;
params[1].asstring:=xyf;
open;
tbl_dest.TableName:='ypbm';
try
BatchMove1.Execute;
except
showmessage('无法更新');
end;
close;
sql.clear;
sql.add('select * from jxbm');
open;
tbl_dest.TableName:='jxbm';
try
BatchMove1.Execute;
except
showmessage('无法更新');
end;
close;
end;
showmessage('更新完毕');