Page 1 of 1

Index Help Neede

Posted: 08.10.2014, 22:49
by Beast Power
I am new to MySql and Zeos, I have a app thet connects to a MySql Database and everything works fine except some of the functions are very slow as I use a ztable.locate command to find records.

What I need is to know is what is the equivalent of the TTable.Indexname and TTable.Findkey Command with the zeos library ? (Have searched but really need help now)

Re: Index Help Neede

Posted: 22.10.2014, 06:18
by Sergiomaster
Hello,

Findkey is a 'bad habit IMO , findkey is looking in the loaded dataset (that was great with a paradox table, loaded in memory , but not for a table in a SGBD overall if not local)
Use a ZQuery (or TZReadOnlyQuery) with a select containing a where clause .

i.e

Code: Select all

SELECT * FROM  CUSTOMERS WHERE IDNUMBER=:N
Where N is a parameter and IDNUMBER is one of the Index (not necessary but better) primary or not , unique (preferably or not)

usage

Code: Select all

TZReadOnlyQuery.Active:=False;
TZReadOnlyQuery.ParambyName('N').asINteger:=100;
TZReadOnlyQuery.Active:=True;
if TZReadOnlyQuery.FieldByName('IDNUMBER').isnull 
  then showmessage('Not found')
  else .....