Recent

Author Topic: Creating and index on a numeric/integer field [SOLVED]  (Read 915 times)

1HuntnMan

  • Full Member
  • ***
  • Posts: 150
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Creating and index on a numeric/integer field [SOLVED]
« on: November 19, 2023, 10:45:36 pm »
Researching and can't seem to find how to create an index on a integer field.  See the snipet below:

 Clients.Open;
     {Add the primary index}
     Clients.AddIndex('CUSTID','CUSTNO',[ixPrimary, ixUnique]);
     {Add a secondary indexes}
     Clients.AddIndex('CUSTNAME','CUSTOMER',[ixCaseInsensitive]);
==>     Clients.AddIndex('CNTKIDNO','CNTKID',[ixInteger]);  // Error here on ixInteger!!!!
     Clients.AddIndex('CITYSTCTRY','CITYTOWN+STATEPROVINCE+COUNTRY',[ixCaseInsensitive]);
     Clients.AddIndex('TYPECUST','CUSTTYPE',[ixCaseInsensitive]);
     Clients.Close;

Trying to find all the ix's that can be used Adding Indexes:
    ixPrimary, ixUnique, ixCaseInsensitive and what else.  How would you create an index on an integer field?
« Last Edit: December 15, 2023, 03:18:30 pm by 1HuntnMan »

dsiders

  • Hero Member
  • *****
  • Posts: 1013
Re: Creating and index on a numeric/integer field
« Reply #1 on: November 20, 2023, 12:01:37 am »
Researching and can't seem to find how to create an index on a integer field.  See the snipet below:

 Clients.Open;
     {Add the primary index}
     Clients.AddIndex('CUSTID','CUSTNO',[ixPrimary, ixUnique]);
     {Add a secondary indexes}
     Clients.AddIndex('CUSTNAME','CUSTOMER',[ixCaseInsensitive]);
==>     Clients.AddIndex('CNTKIDNO','CNTKID',[ixInteger]);  // Error here on ixInteger!!!!
     Clients.AddIndex('CITYSTCTRY','CITYTOWN+STATEPROVINCE+COUNTRY',[ixCaseInsensitive]);
     Clients.AddIndex('TYPECUST','CUSTTYPE',[ixCaseInsensitive]);
     Clients.Close;

Trying to find all the ix's that can be used Adding Indexes:
    ixPrimary, ixUnique, ixCaseInsensitive and what else.  How would you create an index on an integer field?

Valid index options are: https://dsiders.gitlab.io/lazdocsnext/fcl/db/tindexoptions.html.

You should not need anything other than the name for the index and the name of the field:

Code: Pascal  [Select][+][-]
  1. Clients.AddIndex('CNTKIDNO', 'CNTKID', []);

It already knows the type for the underlying field.



« Last Edit: November 20, 2023, 12:16:34 am by dsiders »
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

1HuntnMan

  • Full Member
  • ***
  • Posts: 150
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Creating and index on a numeric/integer field
« Reply #2 on: November 20, 2023, 12:50:39 pm »
Tks DSiders, that was too easy...

1HuntnMan

  • Full Member
  • ***
  • Posts: 150
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Creating and index on a numeric/integer field
« Reply #3 on: November 20, 2023, 01:01:26 pm »
How do you label a subject SOLVED?  I see this throughout the system on questions that were SOLVED.  Do you just add the word SOLVED to the Subject?

Zvoni

  • Hero Member
  • *****
  • Posts: 2229
Re: Creating and index on a numeric/integer field
« Reply #4 on: November 20, 2023, 01:37:39 pm »
How do you label a subject SOLVED?  I see this throughout the system on questions that were SOLVED.  Do you just add the word SOLVED to the Subject?
"Modify" your first post, and edit the Subject-Line with "[SOLVED] ....."
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018