Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sorting numeric fields within char fields
Message
 
 
À
22/10/2001 00:44:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00571538
Message ID:
00571544
Vues:
31
This message has been marked as the solution to the initial question of the thread.
Hi!

Your index expression should look like following:

ClientCode + Str(NumericField + 100000000, 10)

User will not know that all numbers are increased by great value just for sorting. This way you eliminate negative values, index expression is simple, order will be correct and no much of changes required to correct SEEK for interactive search.

HTH.

>Hi All
>
>I have a table containing several million client records. There are multiple records per client. Each client has a unique 8 character code. Each record also contains a date and a numeric field, amongst others.
>
>I can easily sort the table by Client_Code + date by creating an index on Client_Code + Dtos(Date_Field). My problem is I also need to sort the records by the numeric field within client code. i.e. Client_code + Numeric_Field.
>
>I tried Client_Code + Str( Numeric_Field, 10 ) which works as long as the Numeric_Field contains positive numbers. When the Numeric_Field contains negative numbers then the Str() function will not sort the field correctly by numeric value but, obviously, by the ASCII value of the resulting Str() function .... negative numbers appear after the largest positive numbers because of the '-' sign.
>
>It is not just sorting that I need but the ability to Seek() to the closest matching numeric value within a specific Client_Code (nag, nag, nag). e.g. in pseudo code:
>
>Set Near On
>=Seek( Client_Code + Numeric_Field )
>Set Near Off
>
>I realize that I could read through all client records or Select all client records and then index and seek the resulting subset of records. However, there can be several thousand client records and it grows daily. Plus I need to create a report of closest matching records (by numeric field) for all clients everyday!
>
>Any ideas? Thanks.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform