Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I triger a field validation for a primary key
Message
From
10/10/1997 09:14:39
 
 
To
10/10/1997 06:21:59
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00052119
Message ID:
00054036
Views:
48
>>>>>I've got a little bit different but still associated with the above issue question. There's a user-entered field that should be unique. So, I use candidate index which is checked when user tries to save changes with tableupdate(). The bad thing is that deleted records are also checked unless I use filter for not deleted() (goodbye Rushmore :( ). The workaround that I see is to use two indices on that field (w/ and w/o filter).
>>>>>
>>>>>Does anybody have better solutions?
>>>>>
>>>>>Thanks in advance.
>>>>
>>>>You could use following solution:
>>>>1. You have candidate index (no filter).
>>>>2. When you try to save a record and trap duplicate key error, you can check >deleted() status of the existing record and, if deleted=.t., recycle it.
>>>
>>>Thanks, Edward. I tried that approach and here some of my thoughts:
>>>
>>>1. This works only with views. When I used table (ether with record or table buffering) I couldn't move record pointer to check if the record with the same field value is deleted. The error "The uniqueness of ...bla,bla,bla violated" occured when I tried to do that.
>>>
>>>2. What if user doesn't add a record but changes the existing one? How do I recycle the deleted record? I tried to REPLACE the unique field of the deleted record with the STR(primary key)(I use surrogate Integer keys) of that record, assuming that the field is a string and user can't put numbers in it. So the value would be unique.But it won't work with numeric fields.
>>>
>>>Thanks, again.
>>
>>Didn't you know that I don't use buffering?
>
>I didn't know that when I wrote my message. Now I know that you don't use variables eather. Could you explain your approach to editing data in detail?. Do you always use views?
>
>>BTW, VFP6 will have function allowing SEEKing without moving pointer. In regard >to second problem: it's not difficult to have routine finding new 'unique' key >value to shift out deleted record. BTW, the normal process could also involve >'safe deletion': when you delete a record, candidate key values get replaced by >some reserved sequence (e.g. "000001","000002", etc.).
>
>I thought about it. The problem is you can't do it in Delete Trigger (the natural place to do it). So I'll lack flexibility using my own delete routine.
>Also, as I said before it won't work with numeric fields if user can type any numeric value (even negative).However it's a rather rare case.
>
>>Privet Sevastopolyu.
> :) Spasibo. I vam zdraste.

I don't use memory variables. Instead of this, I use PEMs and unbound controls, i.e. any form (class) has generic custom method which populate Control.Value or Caption, etc. properties by field values. When it's ready to save, another code Insert or Replace field values from control properties.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform