Board index » delphi » Creating secondary index during runtime

Creating secondary index during runtime

I have a master/detail relationship between two Paradox tables that I
create during runtime. I'm sucessful at creating the primary index for
each of the tables, but I can't figure out how to build the secondary
index for the detail table. Any clues or code on how to create it?

BTW, using Database Desktop is not an option; I have to do all of this
during runtime.

 

Re:Creating secondary index during runtime


On Wed, 08 Sep 1999 17:56:33 GMT, robert.pow...@edionline.com (Robert

Quote
Powell) wrote:
>I have a master/detail relationship between two Paradox tables that I
>create during runtime. I'm sucessful at creating the primary index for
>each of the tables, but I can't figure out how to build the secondary
>index for the detail table. Any clues or code on how to create it?

>BTW, using Database Desktop is not an option; I have to do all of this
>during runtime.

One way would be to use the TTable.AddIndex method. For instance, on the
Detail table's field named SomeField:

  Table1.AddIndex('SomeField', 'SomeField', []);

Another way is to use the local SQL statement CREATE INDEX. Execute the
statement from a TQuery using its ExecSQL method.

  CREATE INDEX SomeField ON TableName (SomeField)

Local SQL (what the BDE uses for dBASE, Paradox, and FoxPro tables) is
documented in the online help file LOCALSQL.HLP, found in the main BDE
directory. This help file is a language reference of the local SQL
implementation (subset) of SQL-92. The copy of this file that came with BDE
4.x (and earlier versions) was outdated and has since been rewritten.
Updated copies will have the topic "Unsupported language" in the index (and
lack of this topic indicates a pre-update copy). I can e-mail you a copy of
the updated file if you need and desire it.

And still another way is to use the BDE API function DbiAddIndex,
documented in the BDE API help. But as the TTable.AddIndex method is a
wrapper around this API function, there is seldom a pressing need to use
it.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

Re:Creating secondary index during runtime


On Wed, 08 Sep 1999 21:09:27 GMT, koter...@NOSPAMgte.net (Steve

Quote
Koterski) wrote:
>On Wed, 08 Sep 1999 17:56:33 GMT, robert.pow...@edionline.com (Robert
>Powell) wrote:

>>I have a master/detail relationship between two Paradox tables that I
>>create during runtime. I'm sucessful at creating the primary index for
>>each of the tables, but I can't figure out how to build the secondary
>>index for the detail table. Any clues or code on how to create it?

>>BTW, using Database Desktop is not an option; I have to do all of this
>>during runtime.

>One way would be to use the TTable.AddIndex method. For instance, on the
>Detail table's field named SomeField:

>  Table1.AddIndex('SomeField', 'SomeField', []);

I tried that:

   Add('ProfileListIndex', 'ProfileNumb' , []);

I always get "Invalid index/tag name".

Quote

>Another way is to use the local SQL statement CREATE INDEX. Execute the
>statement from a TQuery using its ExecSQL method.

>  CREATE INDEX SomeField ON TableName (SomeField)

Thats what I'll try next.

Other Threads