Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary Index Key on multiple fields.
Message
From
19/04/2002 10:04:07
 
 
To
19/04/2002 09:42:42
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00646879
Message ID:
00646893
Views:
18
>Hi All,
>
>We would like to have a Primary index key that is based on more than 1 field. i.e. Po_no N(11), po_ln_no N(11). I know po_no + po_ln_no will SUM() the 2 columns. We tried PADL(TRANS(po_no), 11, '0') + PADL(TRANS(po_ln_no), 11, '0') This does not work. But we have no idea why not. We keep getting an error saying the uniqueness of the index has been violated.
>
>Can it be done? If so, what did we miss?
>
>VFP6 SP5 - The database is a standard VFP '.dbc'
>
>TIA
>Mike

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
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform