Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of 'primary_key' is violated.
Message
From
18/09/2004 16:42:32
 
 
To
05/09/2004 04:30:06
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00939529
Message ID:
00943776
Views:
22
>Hi everybody,
>
>I'm sure most of you must have seen this error message before.
>
>This is the scenario I experienced.
>
>I have a customer master file(single table) in a DBC with a primary key(cust_no).
>When the user deletes a customer record it uses DELETE command. The PACK command is issued to clear the deleted records only when another monthly routine program is run at the end of each month. Cust_no is alphanumeric.
>
>Before PACKing the table if another user enters a new customer with a customer number that is already deleted, it gives me the following error message.
>
> Uniqueness of cust_no is violated.
>
>I have issued SET DELETED ON command before entering the new customer. But VFP seems to keep track of deleted primary keys also in the index file(CDX).
>
>Can anyone tell me how to tell VFP not to keep track of deleted keys, or any other work arround so that I can enter new customer codes disregarding the deleted keys.
>
>Your help is greatly appreciated.

I'm coming to this very late so sorry if I've missed something.

You can add a filter to the index " for deleted()=.f. " and then uniqueness will not be violated if you want to reuse a key.

I know this works with candidate keys.

SET RANT ON

FWIW you are keying on DATA ! Don't want to start a religious war here but my own 2 cents is nevernevernevernever key on data ( i.e. something the user sees and can change ) The PK would be better off being a guid or being system generated and the cust_no being a candidate key

SET RANT OFF < bg >


>
>Don


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform