此函数的功能是实现用一个表中选出合适的句子,做修改后在追加到表中用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;