Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary Index Key on multiple fields.
Message
From
19/04/2002 11:12:13
 
 
To
19/04/2002 10:19:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00646879
Message ID:
00646927
Views:
17
>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform