Board index » delphi » Searching on the Secondary Key

Searching on the Secondary Key

How is it possible to do a search on the secondary key of a two key table?

TTable.findkey([?,Searchkey]);

I just want to index off of the secondary key, how do I do this without
putting a value in for the primary key?

Sterling.

 

Re:Searching on the Secondary Key


Quote
In article <45us98$...@druid.borland.com> koter...@borland.com (Steve Koterski) writes:
>From: koter...@borland.com (Steve Koterski)
>Subject: Re: Searching on the Secondary Key
>Date: Tue, 17 Oct 1995 00:09:57 GMT
>smo...@indirect.com (Sterling Moses) wrote:
>>How is it possible to do a search on the secondary key of a two key table?

>>TTable.findkey([?,Searchkey]);

>>I just want to index off of the secondary key, how do I do this without
>>putting a value in for the primary key?
>Were you asking how to use a secondary index for a search? Or (I think more
>likely) how to search on the second of two fields in a composite primary
>key or secondary index?
>If the latter, then no. You would be able to specify values (in the
>FindKey) for the first field only or for the first and second fields. You
>cannot "skip" a field in a multi-field index.
>If this is what you need to do, look at creating a secondary index based
>just on this second field for purposes of ordering, searching, and
>filtering.

How would one go about doing this. I looked through the on-board help and a
lot of books, but it must have escaped me. I would very much appreciate a slip
of code if you could...

Sterling.

Re:Searching on the Secondary Key


Quote
smo...@indirect.com (Sterling Moses) wrote:
>In article <45us98$...@druid.borland.com> koter...@borland.com (Steve Koterski) writes:
>>From: koter...@borland.com (Steve Koterski)
>>Subject: Re: Searching on the Secondary Key
>>Date: Tue, 17 Oct 1995 00:09:57 GMT

>>smo...@indirect.com (Sterling Moses) wrote:

>>>How is it possible to do a search on the secondary key of a two key table?

>>>TTable.findkey([?,Searchkey]);

>>>I just want to index off of the secondary key, how do I do this without
>>>putting a value in for the primary key?

>>Were you asking how to use a secondary index for a search? Or (I think more
>>likely) how to search on the second of two fields in a composite primary
>>key or secondary index?

>>If the latter, then no. You would be able to specify values (in the
>>FindKey) for the first field only or for the first and second fields. You
>>cannot "skip" a field in a multi-field index.

>>If this is what you need to do, look at creating a secondary index based
>>just on this second field for purposes of ordering, searching, and
>>filtering.

>How would one go about doing this. I looked through the on-board help and a
>lot of books, but it must have escaped me. I would very much appreciate a slip
>of code if you could...

You can create a secondary index interactively through the Database Desktop
utility (DBD) or programmatically. Using the DBD, you can create one or
more secondary indexes to a table when you create the table. Select
"Secondary Indexes" from the Table Proper combobox, and follow the prompts
(see the section on the DBD in the Database Applications Developer's Guide,
page 154, "Defining secondary indexes.") You can also add one or more
secondary indexes to an existing table in DBD. Use the menu options
Utilities|Restructure. Once in the restructure dialog, the process is the
same as when adding indexes to a new table under construction.

Programmatically, indexes may be added to a table being created with the
CreateTable method of the TTable component. You will need to fill a
TIndexDef structure for each index. (See the example in the on-line help
topic for the CreateTable method.) For existing tables, use the AddIndex
method of the TTable.

**************************************************************************
Steve Koterski
Product Group Manager
Delphi Technical Support
Borland International, Inc.

Other Threads