The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Hi,
I wanted to remove some fields and filtered records from a zMemTable at runtime (but not to alter the file that I originally loaded the data from).
Current I do it by copying the fields/records that I want to temporary memtable and than clone it to the original memtable (see code below). Long cut ... because I dont know how to deleted fields.
Any advice
would be much appreciated.
procedure AltTable(mt: TZMemTable; ls: array of integer); // ls contains the fields (number) that I want to keep
var tmp: TZMemTable; ii: integer;
begin
tmp := TZMemTable.Create(nil);
try
for ii := 0 to high(ls) do
with mt.Fields[ls[ii]] do
tmp.FieldDefs.Add(FieldName, DataType, Size, Required);
tmp.Open;
mt.First;
while not mt.eof do
with tmp do
begin
Append;
for ii := 0 to FieldCount -1 do
Fields[ii].Value := mt.Fields[ls[ii]].Value;
Post;
mt.Next;
end;
mt.Close;
mt.CloneDataFrom(tmp);
{ tmp.SaveTofile('tmp');
mt.LoadFromFile('tmp'); }
finally
tmp.free
end;
end;
aehimself:
No luck.
Memtable.Fieldbyname('somefield').Free results in 'Access violation' error.
MemTable.Delete can delete a record that is visible (i.e. not filtered out). My question is how to delete all records that are filtered out (not visible). I use CloneDataFrom because it would copy records that are filtered out.
It would be more interesting and relatively simple to write/read parts (from-to) of the ZMemTable to/from disk, and merge data.
Though it might actually be useful to copy the definitions of the specified fields and data to the ZMemTable.
It would be more interesting and relatively simple to write/read parts (from-to) of the ZMemTable to/from disk, and merge data.
Though it might actually be useful to copy the definitions of the specified fields and data to the ZMemTable.
Michał
Thanks for your reply. Your suggestion is the similar to what I was trying to do with the code above. Right?
Note that you can copy the structure without some fields.
As well as adding new fields.
And copy the data in a traditional way, indicating the correct ones.
In fact, a library of such routines, the ZMemTableUtils, would come in handy.
miab3 wrote: ↑17.11.2021, 10:04
Hi kjteng,
...
As well as adding new fields.
And copy the data in a traditional way, indicating the correct ones.
In fact, a library of such routines, the ZMemTableUtils, would come in handy.
Michał
OK I see your point. Thank you for the valuable advice.
Where can I find ZMemTableUtils.pas ?