Board index » delphi » Syntax for checking the existence of a secondary Index

Syntax for checking the existence of a secondary Index

I want to check whether a temp, secondary index exists before I try to
delete it.

I can't work out the syntax along the lines of:-

If DataModule1.DBInc.IndexName('TempIndexName').Exists then

Could someone put me out of my misery :-).

TIA

Ed

 

Re:Syntax for checking the existence of a secondary Index


if Table1.IndexDefs.Find('MyIndexName') <> nil then...

--
Bill
(TeamB cannot answer questions received via email)

Re:Syntax for checking the existence of a secondary Index


:-) and thanks as always.

If I am using the datamodule structure the indexdefs.find option isn't
available.

Is the following acceptable in lieu?

if DataModule1.DBInc.IndexDefs.FindIndexForFields('CLI_Name;Date') <>
nil then DataModule1.DBInc.DeleteIndex('DateColclitemp');

TIA

Ed

Re:Syntax for checking the existence of a secondary Index


That is fine although I know of no reason why Find will not work. Can you
show me the code that fails and the error message?

--
Bill
(TeamB cannot answer questions received via email)

Re:Syntax for checking the existence of a secondary Index


As it stands I get an error message:-

Project test has raised exception class DatabaseError with message
"DBinc" has no index for fields "CLI_Name;Date". Process Stopped...

Which I don't understand as that is exactly what it is trying to test
for!

However I changed the syntax to

DataModule1.DBInc.IndexDefs.GetIndexForFields('CLI_Name;Date',False)

and it's happy and so am I.

Ed

Re:Syntax for checking the existence of a secondary Index


With Find you have to use the name of the index, not the name of the fields
in the index. What you are doing is correct if you want to use the field
names.

--
Bill
(TeamB cannot answer questions received via email)

Other Threads