Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary Index Key on multiple fields.
Message
De
19/04/2002 11:12:13
 
 
À
19/04/2002 10:19:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00646879
Message ID:
00646927
Vues:
18
>>Mike,
>>
>>THe uniqueness error may come from either (1) deleted records or (2) records that are not deleted and actually contain duplicate data
>>
>>(2) cannot be solved, you have to find them
>>
>>(1) can be solved as follows provided the numbers are >= 0
>>
>>
>>alter table TheTable ;
>>   add primary key strtran(str(po_no,11,0) + str(po_ln_no,11,0), ' ', '0')  for !deleted() tag Id
>>
>
>Hi Gregory,
>
>1) We were carefull to insure against the Deleted records. We got caught a few years ago on that one.
>
>2) There were no other records with an identical po_no & po_ln_no combination.
>
>Mike

Mike,

If you get an error, then it's (1) and/or (2)

To find out
set deleted Off

select po_no, ;
       po_ln_no, ;
       cnt(*) ;
    from Table ;
    group by 1, 2 ;
       having cnt(*) > 1
or
set deleted Off

select strtran(str(po_no,11,0) + str(po_ln_no,11,0), ' ', '0') as KeyExpr ;
   from Table ;
   into cursor tmp

select KeyExpr, ;
       cnt(*) ;
    from tmp ;
    group by 1 ;
    having cnt(*) > 1
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform