Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Index order
Message
De
25/08/2006 14:09:34
 
 
À
25/08/2006 13:25:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01148655
Message ID:
01148670
Vues:
14
>Hi.
>I have a table named 'artigos' with a .cdx index with three index keys:
> CODIGO_PRO - Numeric
> DESIGNACAO - Character
> DATA_REGIS - Date
>
>If I want to order the records by CODIGO_PRO is: "SET ORDER TO TAG CODIGO_PRO IN artigos".
>But, CODIGO_PRO is a code for a type of product. Of course I have all the products of each type together.
>Now, if I want the DESIGNACAO key to be my second order key how I say that CODIGO_PRO is my first order key and after ordering by CODIGO_PRO the records must be ordered by DESIGNACAO (my second index key)?

There are at least 3 general ways you could do this:

1. If you want to use an index tag, the tag must be of one type (as you've found). So, convert one of the fields e.g.
INDEX ON PADL( STR( CODIGO_PRO ), 6, "0" ) + DESIGNACAO
Note that you would have to SEEK() etc. on this expression, which can be a pain.

2. You could create a view and use that. A view is basically a SELECT - SQL statement, which can include an ORDER BY clause using columns of different types.

3. Some people believe that numeric fields should be used only for values on which you'll be doing mathematical computations e.g. addition, multiplication etc. In your case, although CODIGO_PRO has a numeric appearance, it's actually an identifier. In general you might want to consider using an character field instead of numeric. Sometimes it can mean a little more work e.g. if someone enters "1" you might want to store it as "000001" so your indices work as expected - it's a trade-off.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform