Author: Tomas Rutkauskas
When I have deleted an in-memory table and I want to create it again, I get an
error message that I have duplicate field names. What is wrong here?
Answer:
This automatically creates and destroys memory tables as needed. Use these
procedures to open and close your tables.
1 procedure OpenTbl(Tbl: TDBISAMTable);
2 begin3 if (Tbl.Active = False) then4 begin5 with Tbl do6 begin7 try8 ifnot (Exists) and InMemory then9 CreateTable;
10 Open;
11 First;
12 except13 raise EOpenTable.Create('Error: couldn' t open table.('+Tbl.TableName+':
14 '+Tbl.Name+')');
15 end;
16 end;
17 end;
18 end;
19 20 procedure CloseTbl(Tbl: TDBISAMTable);
21 begin22 with Tbl do23 begin24 if (Active = True) then25 begin26 if (state = dsInsert) or (state = dsEdit) then27 begin28 try29 Post;
30 except31 Cancel;
32 end;
33 end;
34 Tbl.FlushBuffers;
35 Close;
36 if InMemory then37 begin38 try39 DeleteTable;
40 except41 { ... }42 end;
43 end;
44 end;
45 end;
46 end;