Elevate Software Logo

Contacts | Partners | Links





Technical Support

Home > Technical Support > Frequently Asked Questions > View Frequently Asked Question




I need to provide the equivalent functionality that is provided in the TBatchMove component provided with the BDE, can I do this with DBISAM ?

Yes, just use the following code to provide TBatchMove type of functionality in DBISAM.

TDBISAMBatchMoveType = (bmtAppend,bmtAppendUpdate,bmtCopy,
                        bmtDelete,bmtUpdate);

procedure BatchMove(SourceTable, DestTable: TDBISAMTable;
                    MoveType: TDBISAMBatchMoveType);
var
   I: Integer;
   FieldPos: Integer;
   RecordWasFound: Boolean;
begin
   SourceTable.DisableControls;
   DestTable.DisableControls;
   try
      with SourceTable do
         begin
         Open;
         FieldDefs.Update;
         IndexDefs.Update;
         end;
      with DestTable do
         begin
         if (not Exists) or (MoveType=bmtCopy) then
            begin
            Close;
            FieldDefs.Assign(SourceTable.FieldDefs);
            IndexDefs.Assign(SourceTable.IndexDefs);
            CreateTable(SourceTable.LocaleID,
                        SourceTable.UserMajorVersion,
                        SourceTable.UserMinorVersion,
                        SourceTable.Encrypted,
                        SourceTable.Password,
                        SourceTable.Description,
                        SourceTable.IndexPageSize,
                        SourceTable.BlobBlockSize,
                        SourceTable.LastAutoIncValue);
            end;
         Open;
         IndexName:='';
         end;
      DestTable.LockTable;
      try
         with SourceTable do
            begin
            IndexName:='';
            First;
            end;
         while not SourceTable.EOF do
            begin
            RecordWasFound:=False;
            if (MoveType in [bmtAppend,bmtAppendUpdate,
                             bmtUpdate,bmtDelete]) then
               begin
               DestTable.SetKey;
               for I:=0 to DestTable.IndexFieldCount-1 do
                  begin
                  DestTable.IndexFields[I].Assign(
                    SourceTable.FieldByName(
                      DestTable.IndexFields[I].FieldName));
                  end;
               RecordWasFound:=DestTable.GotoKey;
               end;
            if RecordWasFound then
               begin
               if (MoveType in [bmtAppendUpdate,
                                bmtUpdate]) then
                  begin
                  DestTable.Edit;
                  for I:=0 to SourceTable.FieldCount-1 do
                     DestTable.FieldByName(
                       SourceTable.Fields[I].FieldName).
                         Assign(SourceTable.Fields[I]);
                  DestTable.Post;
                  end
               else if (MoveType=bmtDelete) then
                  DestTable.Delete;
               end
            else
               begin
               if (MoveType in [bmtAppend,bmtAppendUpdate,
                                bmtCopy]) then
                  begin
                  DestTable.Insert;
                  for I:=0 to SourceTable.FieldCount-1 do
                     DestTable.FieldByName(
                       SourceTable.Fields[I].FieldName).
                         Assign(SourceTable.Fields[I]);
                  DestTable.Post;
                  end;
               end;
            SourceTable.Next;
            end;
      finally
         DestTable.UnlockTable;
      end;
   finally
      SourceTable.EnableControls;
      DestTable.EnableControls;
   end;
end;





Related Pages

Option Newsgroups (Web)

Option Newsgroups (News Server)

Option Incident Reports

Option Roadmap

Option Technical Bulletins

Option Technical Articles

Option Product Manuals

Option Product Roadmaps






This web page was last updated on
Monday, October 27, 2008 at 03:27 PM

Valid HTML 4.01!  Valid CSS!


Privacy Policy

© 2008 Elevate Software, Inc. All Rights Reserved
Questions or comments ? E-mail us at info@elevatesoft.com