ZMemtable, How to create a dataset and findkey?

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
Post Reply
hamacker
Junior Boarder
Junior Boarder
Posts: 37
Joined: 13.10.2021, 15:15

ZMemtable, How to create a dataset and findkey?

Post by hamacker »

Hi All,

I´am trying to use zMemtable as Delphi Client Dataset, but it´s my first time with Zeos 8 Memtable, how Can I Create a dataset in runtime memory, create index and find key fields? I create this sample, but something is wrong, can you help me? Follow:
// sample
zMemTable1.FilterOptions:=[foCaseInsensitive];
zMemTable1.FieldDefs.Clear;
zMemTable1.FieldDefs.Add('status', ftString, 3, False);
zMemTable1.FieldDefs.Add('seq', ftInteger, 0, False);
zMemTable1.FieldDefs.Add('filename', ftString, 1024, False);
zMemTable1.FieldDefs.Add('filepath', ftString, 1024, False);
zMemTable1.CreateDataSet; // not exists CreateDataSet ?
zMemTable1.Active:=true;
zMemTable1.IndexFieldNames:='filename;filepath'; // is it right to use two fields?
if not zMemTable1.FindKey(['arq.exe', 'c:\temp']) then // there is no FindKey?
begin
// not found ...
end;

In this sample does not exists zMemTable1.CreateDataSet, can I continue without that?
In this sample I use zMemTable1.IndexFieldNames:='filename;filepath' to create a index with two fields, is it right?
In this sample I try to find a record with two values accord with IndexFieldNames zMemTable1.FindKey(['arq.exe', 'c:\temp']), but there is not FindKey method, how to find them?

Any hjelp will be welcome.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemtable, How to create a dataset and findkey?

Post by aehimself »

hamacker wrote: 21.07.2023, 14:59In this sample does not exists zMemTable1.CreateDataSet, can I continue without that?
Yes, that is correct.
hamacker wrote: 21.07.2023, 14:59but there is not FindKey method, how to find them?
Unfortunately I cannot help you wit index fields as I never used them, but you can locate even non-index fields:

Code: Select all

If Not ZMemTable1.Locate('filename;filepath', VarArrayOf(['arq.exe', 'c:\temp']), []) Then
  // Not found
Maybe VarArrayOf is not needed in this particular example but for variables you'll have to use it for sure.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply