此函数的功能是实现用一个表中选出合适的句子,做修改后在追加到表中用update不能直接实现。所以就先建了一个临时表,把数据读到临时表中,在用update修改后用batchmove 的batAppend追加到表中!速度其慢procedure Tp_choose_exp.move_datatoNewkeycode(newkeycode,oldkeycode:string);
var
str:string;
procedure updatedata(strtablename:string);
var
tmpquery:Tquery;
i:integer;
TmpDir,VarField,tmpstr0,tmpstr1:string;
CustTable:TTable;
CustQry:TQuery;
CustBatmove:TBatchMove;
DONE:boolean;
begin
CustTable:=TTable.Create(self);
with CustTable do
begin
Active:=False;
DatabaseName:=tempalias;
TableType:=ttdefault;
TableName:='TaskDone.DBF';
with FieldDefs do
begin
Clear;
Add('Field1', ftInteger, 0, True); //临时用
end;
CreateTable;
end; CustQry:=TQuery.Create(self);
with CustQry do
begin
Active:=False;
DatabaseName:='fcgl';
close;
Sql.Clear;
Params.Clear;
Sql.Add('select * from '+strtablename+ ' where keycode=:keycode');
parambyname('keycode').asstring:=oldkeycode;
CustBatmove:=TBatchMove.Create(self);
with CustBatmove do
begin
Destination:=CustTable;
Source:=CustQry;
Mode:=BatCopy;
Execute;
end; CustQry.Free;
CustBatmove.Free;
CustTable.Free;
with p_dm_log.qry_tmp do
begin
DatabaseName:=tempalias;
Close;
Sql.Clear;
Params.Clear;
Sql.Add('update taskdone set keycode=:keycode');
parambyname('keycode').asstring:=newkeycode;
execsql;
end;
with p_dm_log.qry_tmp do
begin
DatabaseName:=tempalias;
Close;
Sql.Clear;
Params.Clear;
Sql.Add('select * from taskdone');
open;
end;
{ with p_dm_log.qry_log do
begin
close;sql.Clear;
sql.Add('insert into '+tablename+' select * from '+ p_dm_log.qry_tmp);
execsql;
end; }
CustTable:=TTable.Create(self);
with CustTable do
begin
Active:=False;
DatabaseName:='fcgl';
TableType:=ttdefault;
TableName:=strtablename;
end;
CustBatmove:=TBatchMove.Create(self);
with CustBatmove do
begin
Destination:=CustTable;
Source:=p_dm_log.qry_tmp;
Mode:=batAppend;
Execute;
end; // CustQry.Free;
CustBatmove.Free;
CustTable.Free;
end;
end;
begin begintransaction;
with p_dm_log.qry_log do
begin
//new_change 表
close;sql.Clear;
sql.Add('insert into new_change(n_keycode,o_keycode,change_type) values(:n_keycode,:o_keycode,:change_type)');
parambyname('n_keycode').asstring:=newkeycode;
parambyname('o_keycode').asstring:=oldkeycode;
parambyname('change_type').asstring:='测绘';
execsql;
//workstep 表 只移交收件
************************************************************
updatedata('workstep'); //速度快
updatedata('filein'); //速度慢
updatedata('info');
updatedata('land');
updatedata('room');
updatedata('build'); //其慢无比
***********************************************************
//修改workstep
close;sql.clear;
sql.add('select sub_type from filein where keycode=:keycode');
parambyname('keycode').asstring:=newkeycode;
open;
str:='';
if not eof then
str:=fields[0].asstring; close;sql.Clear;
sql.Add('delete from workstep where keycode=:keycode and case_proc<>''收件''');
parambyname('keycode').asstring:=newkeycode;
execsql;
close;sql.clear;
sql.add('update workstep set done_name=:done_name,plan_name=:plan_name,case_type=:case_type where keycode=:keycode');
sql.add('update filein set _type=:case_type,sub_type=:sub_type where keycode=:keycode');
sql.add('update info set operator=:plan_name where keycode=:keycode');
parambyname('done_name').asstring:='';
parambyname('plan_name').asstring:=main_form.usename;
parambyname('case_type').asstring:=str;
parambyname('keycode').asstring:=newkeycode;
parambyname('sub_type').asstring:='';
execsql; end;
committransaction;
end;
var
str:string;
procedure updatedata(strtablename:string);
var
tmpquery:Tquery;
i:integer;
TmpDir,VarField,tmpstr0,tmpstr1:string;
CustTable:TTable;
CustQry:TQuery;
CustBatmove:TBatchMove;
DONE:boolean;
begin
CustTable:=TTable.Create(self);
with CustTable do
begin
Active:=False;
DatabaseName:=tempalias;
TableType:=ttdefault;
TableName:='TaskDone.DBF';
with FieldDefs do
begin
Clear;
Add('Field1', ftInteger, 0, True); //临时用
end;
CreateTable;
end; CustQry:=TQuery.Create(self);
with CustQry do
begin
Active:=False;
DatabaseName:='fcgl';
close;
Sql.Clear;
Params.Clear;
Sql.Add('select * from '+strtablename+ ' where keycode=:keycode');
parambyname('keycode').asstring:=oldkeycode;
CustBatmove:=TBatchMove.Create(self);
with CustBatmove do
begin
Destination:=CustTable;
Source:=CustQry;
Mode:=BatCopy;
Execute;
end; CustQry.Free;
CustBatmove.Free;
CustTable.Free;
with p_dm_log.qry_tmp do
begin
DatabaseName:=tempalias;
Close;
Sql.Clear;
Params.Clear;
Sql.Add('update taskdone set keycode=:keycode');
parambyname('keycode').asstring:=newkeycode;
execsql;
end;
with p_dm_log.qry_tmp do
begin
DatabaseName:=tempalias;
Close;
Sql.Clear;
Params.Clear;
Sql.Add('select * from taskdone');
open;
end;
{ with p_dm_log.qry_log do
begin
close;sql.Clear;
sql.Add('insert into '+tablename+' select * from '+ p_dm_log.qry_tmp);
execsql;
end; }
CustTable:=TTable.Create(self);
with CustTable do
begin
Active:=False;
DatabaseName:='fcgl';
TableType:=ttdefault;
TableName:=strtablename;
end;
CustBatmove:=TBatchMove.Create(self);
with CustBatmove do
begin
Destination:=CustTable;
Source:=p_dm_log.qry_tmp;
Mode:=batAppend;
Execute;
end; // CustQry.Free;
CustBatmove.Free;
CustTable.Free;
end;
end;
begin begintransaction;
with p_dm_log.qry_log do
begin
//new_change 表
close;sql.Clear;
sql.Add('insert into new_change(n_keycode,o_keycode,change_type) values(:n_keycode,:o_keycode,:change_type)');
parambyname('n_keycode').asstring:=newkeycode;
parambyname('o_keycode').asstring:=oldkeycode;
parambyname('change_type').asstring:='测绘';
execsql;
//workstep 表 只移交收件
************************************************************
updatedata('workstep'); //速度快
updatedata('filein'); //速度慢
updatedata('info');
updatedata('land');
updatedata('room');
updatedata('build'); //其慢无比
***********************************************************
//修改workstep
close;sql.clear;
sql.add('select sub_type from filein where keycode=:keycode');
parambyname('keycode').asstring:=newkeycode;
open;
str:='';
if not eof then
str:=fields[0].asstring; close;sql.Clear;
sql.Add('delete from workstep where keycode=:keycode and case_proc<>''收件''');
parambyname('keycode').asstring:=newkeycode;
execsql;
close;sql.clear;
sql.add('update workstep set done_name=:done_name,plan_name=:plan_name,case_type=:case_type where keycode=:keycode');
sql.add('update filein set _type=:case_type,sub_type=:sub_type where keycode=:keycode');
sql.add('update info set operator=:plan_name where keycode=:keycode');
parambyname('done_name').asstring:='';
parambyname('plan_name').asstring:=main_form.usename;
parambyname('case_type').asstring:=str;
parambyname('keycode').asstring:=newkeycode;
parambyname('sub_type').asstring:='';
execsql; end;
committransaction;
end;
解决方案 »
- 超郁闷,N多同样控件触发同样的事件,响应代码也一样,该如何办呢?
- delphi 比如Label1后加点后面不能自动展开
- 各位大侠,求救啊。。在pl/Sql中执行有记录,在ADoquery中执行却没有记录
- 如何使Listview根据大小,自动显示图标?
- 关于下拉列表框的问题
- 请问delphi7的dbexpress支持access吗?默认好像不行,怎么才能让他支持?
- 出100分请教高手,不是高手进来学习一下!
- 菜鸟问题:找一个将浮点型数据转化为整型的函数(在线等待)
- 初学者:vb中自带菜单编辑器,dephi中有吗,是不是必须用控件actionmainmenubar构建菜单
- 函数指针怎么用?
- 在richedit中怎么添加表情符?
- 要得到其实某一例的和,该怎么做
这么多没有时间看
照你前面说的
按理不会太慢
因为我以前拨号传输的时候,也很快
你既然是把数据写到了临时表,只要设置好batchmove的数据源和目标表就可以了。
看你最后的那些语句,不知道干什么用的
http://expert.csdn.net/Expert/topic/2928/2928691.xml?temp=5.147952E-02