![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Sun, May 9 2010 8:09 PM | Permanent Link |
Gregory Sebastian | Hi,
I got the below code for a BatchMove probably from Elevate's website sometime back. The code works fine under DBISam V3.3 but appears to be broken under DBISam V4.29. At runtime, I get the errror "Cannot access index field 'RecordID'. Any ideas on how to fix it for V4 ? Thanks Gregory Sebastian Type 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 //Problem here. At runtime I get Error : "Cannot access index field 'RecordID'" 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; |
Mon, May 10 2010 1:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Gregory,
<< I got the below code for a BatchMove probably from Elevate's website sometime back. The code works fine under DBISam V3.3 but appears to be broken under DBISam V4.29. At runtime, I get the errror "Cannot access index field 'RecordID'. Any ideas on how to fix it for V4 ? >> You can't. Using the batch move code with a primary index that contains the RecordID field won't work because it won't be able to find and update the destination records properly (it uses the primary index to uniquely identify records). This is because the RecordID will possibly be different in the destination records. The bottom line is that you'll need to define a valid primary index on the source table that doesn't refer to the system RecordID field in order to use the batch move code. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, May 10 2010 11:32 PM | Permanent Link |
Gregory Sebastian | Thanks Tim, understood.
Regards Gregory Sebastian |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |