Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking some field for uniqueness
Message
 
 
To
12/06/2001 21:56:36
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00518556
Message ID:
00518693
Views:
17
>>>>Thanks again. So basically COUNT FOR +Trapping uniqueness of index is violated error should work. I have to think about it and discuss with my colleagues. I can make changes for the particular form, but it's better to make the changes on the class level.
>>>
>>>I prefer the SELECT COUNT(*) on the buffered view/table because the count is retrieved into a cursor and leaves the source table as is with the record pointer on the same edited record.
>>
>>Mark,
>>
>>AFAIK, SQL works with table directly, in other words, it would not see the buffered changes. What's why this method in not 100% correct.
>
>But then what are you checking against? How many users are having buffered changes at the same time? Even if there's more than one, you can still run the validation against the disk file - anything in buffers is not accounted for until the moment of saving. So yes, you can have a situation where one user wants to save FNA while there's FNA on disk already, while another user is actually renaming FNA to FNB but it's not saved yet etc - but there's no way you can read someone else's buffers. This means that from the standpoint of one instance of your app, there's no way you can be aware of what the other users are doing, until they (try to) save. So the only thing you can compare against is your own buffers and the disk file.
>
>The method with using the file again and doing a seek() or indexseek() on it will check against the disk file and probably your local changes (still not sure and may need testing). SQL select will read only the disk file. There's no way that I know of that you can do this, unless you turn buffering off.

Hi Dragan,

I want to test value immediatelly after focus is trying to leave the textbox. Additional check would be performed at the stage of saving. So, here is the simple potential scenario:

One userA opens table in buffered mode. He switches to Editmode and go to record 4. He changes FunName to "MyFun1". Then he goes to lunch. After lunch he goes to record 8 and changes funName to "MyFun1" or tries to add a new record with 'myFun1'. Since the changes are not saved on disk yet, your method would allow him to do it. I want to catch this invalid input immediatelly.

So, only COUNT FOR should work (or seek and do while (or scan while)). Since these operations move record pointer, I would have an error, which I should trap. That's why it's quite complicated task and I want to discuss it with colleagues first. Though, I know in advance the answer: yes, we understand the problem, but it's a low priority problem, etc., etc. So this would never be implemented anyway and I have to deal with it on the particular form level...
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform