Board index » delphi » Delphi and dbase database index

Delphi and dbase database index

I am writing a delphi application that create dbase table at runtime.

I need a multifield index, but was unable to create it. I tried the syntax
found in the doc (addindex('indexname','field1;field2',[]); and equivalents)
in all the ways I found, but I never succeed.

Does someone here nows the way ?

Thank you

jcbor...@dialup.francenet.fr (Jean Claude BORNES)

 

Re:Delphi and dbase database index


Jean Claude BORNES (jcbor...@dialup.francenet.fr) wrote:
: I am writing a delphi application that create dbase table at runtime.
:
: I need a multifield index, but was unable to create it. I tried the syntax
: found in the doc (addindex('indexname','field1;field2',[]); and equivalents)
: in all the ways I found, but I never succeed.

I would recommend reading Borland's Technical Information (TI) bulletin
#2838 titled "dBASE Expression Indexes: A Primer" since special care
must be taken when using dBASE expression indexes--which you seem to
be trying to use by specifying the 'field1;field2' parameter.

The quick answer is that your AddIndex() method call should be the
following:

    AddIndex('indexname', 'field1 + field2', [ixExpression]);

Definitely check out the TI for more details.  (Delphi TIs can be found at
"ftp://ftp.borland.com/pub/techinfo/techdocs/language/delphi/ti/",
via Borland's web site
["http://www.borland.com/TechInfo/delphi/techdocs/techdocs.html"],
on the Delphi "update" CD, and through the free, automated "TechFax"
service [U.S.A 1-800-822-4269].)

--
        loveseekstears
stoEhr  hopedeniesfate
        sorrowcannotbe

Re:Delphi and dbase database index


                        Hi Jean!

        I solved this task exactly today! Look on sample code:
-------------
Procedure CreateTodoBase(var WorkTable: TTable; Dir: String);
begin
 WorkTable.Active := False;
 WorkTable.DatabaseName := Dir;
 WorkTable.TableName := 'tasks.dbf';
 WorkTable.TableType := ttDbase;
 WorkTable.FieldDefs.Clear;
 WorkTable.FieldDefs.Add('DATE_C',    ftString,  8,false);
 WorkTable.FieldDefs.Add('TIME_FROM', ftString,  5,false);
 WorkTable.FieldDefs.Add('TIME_TO',   ftString,  5,false);
 WorkTable.FieldDefs.Add('NAME',      ftString, 60,false);
 WorkTable.FieldDefs.Add('PROJECT',   ftString, 20,false);
 WorkTable.FieldDefs.Add('GRP_LIST',  ftMemo,    0,false);
 WorkTable.FieldDefs.Add('REPORT',    ftBoolean, 0,false);
 WorkTable.FieldDefs.Add('KEEP',      ftBoolean, 0,false);
 WorkTable.FieldDefs.Add('SHOW',      ftString,  1,false);
 WorkTable.FieldDefs.Add('WARN_MODE', ftInteger, 0,false);
 WorkTable.FieldDefs.Add('WARN_TIME', ftInteger, 0,false);
 WorkTable.FieldDefs.Add('DONE',      ftBoolean, 0,false);
 WorkTable.IndexDefs.Clear;
 WorkTable.CreateTable;
 WorkTable.AddIndex('MAIN','SHOW+TIME_FROM+TIME_TO',
[ixExpression,ixPrimary]);
end;

-------------

                                                        Gennady

jcbor...@dialup.francenet.fr (Jean Claude BORNES) wrote:

Quote
>I am writing a delphi application that create dbase table at runtime.

>I need a multifield index, but was unable to create it. I tried the syntax
>found in the doc (addindex('indexname','field1;field2',[]); and equivalents)
>in all the ways I found, but I never succeed.

>Does someone here nows the way ?

>Thank you

>jcbor...@dialup.francenet.fr (Jean Claude BORNES)

---
Gennady M. Makeev            Zelinsky Institute of Organic Chemistry
E-MAIL:                              Moscow, Russia
 mak...@cacr.ioc.ac.ru       (095)-135-90-89 (sometimes I aviable even
 m...@hal.chem.msu.su                   at Saturday and Sunday)

 *** PGP key aviable on request ***

Re:Delphi and dbase database index


The syntax for expession indexes for dBase in Dephi is as follows

AddIndex('IndexName','LastName+FirstName',[ixExpression])

The ixExpression parameter is not detailed in the documentation

Another point is that you have to use valid dBase expressions

eg SUBSTR(LastName,1,3) or STR(NoFiled) etc

Hope this helps

Cheers....Maca

Other Threads