Board index » delphi » Create Paradox Secondary Index on the fly?

Create Paradox Secondary Index on the fly?

How do I create Paradox secondary index on the fly?
In other words, a Paradox table contains a lot of data, and I want to do
a search with 2 fields, say 'NowDate' & 'MatMonth' from table AD.db.

Can I use:

with AD
    with IndexDefs do begin
        Clear;
        Add('ADidx', 'NowDate;MatMonth', [ixUnique]);
    end;

    CreateIndex;    //?????????
end;

  lhuynh.vcf
< 1K Download
 

Re:Create Paradox Secondary Index on the fly?


On Tue, 22 Dec 1998 17:21:37 -0600, Long Huynh <lhu...@futuresmag.com>
wrote:

Quote
>How do I create Paradox secondary index on the fly?
>In other words, a Paradox table contains a lot of data, and I want to do
>a search with 2 fields, say 'NowDate' & 'MatMonth' from table AD.db.

>Can I use:

>with AD
>    with IndexDefs do begin
>        Clear;
>        Add('ADidx', 'NowDate;MatMonth', [ixUnique]);
>    end;

>    CreateIndex;    //?????????
>end;

The TIndexDef objects contained in the collection property TTable.IndexDefs
are there to 1) add index defenitions when creating a new table and 2)
inspect existing index definitions. You cannot use the TIndexDef objects to
add new indexes to an already-existing table. However, there are other ways
to do that...

One way is to use the TTable.AddIndex method. (To do this, there must
already be a primary index for the table.)

  Table1.AddIndex('U_IndexName', 'FieldName', [ixUnique]);

Another way is to use the SQL statement CREATE INDEX, executed from a
TQuery.

  CREATE UNIQUE INDEX U_IndexName ON TableName (FieldName)

And still another way is to use the BDE API function DbiAddIndex (explained
in the BDE API online help).

//////////////////////////////////////////////////////////////////////////
Steve Koterski                      "The knowledge of the world is only to
Technical Publications              be acquired in the world, and not in a
INPRISE Corporation                 closet."
http://www.inprise.com/delphi          -- Earl of Chesterfield (1694-1773)

Re:Create Paradox Secondary Index on the fly?


No, you should use SQL:

Query.SQL.clear;
Query.SQL.Add( ' CREATE INDEX DATE_MONTH ON "AD.DB" ( date, month )' );
Query.ExecSQL;

Be sure the table is closed !

By the way: SQL seems tricky, but when you
get the hang of it
you'll feel a genuine wizard !

Kees

Long Huynh heeft geschreven in bericht <36802980.1FF85...@futuresmag.com>...

Quote
>How do I create Paradox secondary index on the fly?
>In other words, a Paradox table contains a lot of data, and I want to do
>a search with 2 fields, say 'NowDate' & 'MatMonth' from table AD.db.

>Can I use:

>with AD
>    with IndexDefs do begin
>        Clear;
>        Add('ADidx', 'NowDate;MatMonth', [ixUnique]);
>    end;

>    CreateIndex;    //?????????
>end;

Other Threads