Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Avoiding Dublicate Field entries in a multi-user applica
Message
From
20/02/1998 11:47:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
20/02/1998 11:29:23
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00080125
Message ID:
00080130
Views:
30
>Am a Visual Foxpro beginner with yet another question.. I need you help on again..
>
>
>I am working on an application that tracks work orders. The work order number field entry is a function of the RECNO() and I want it to be incremented automatically by the program not by the user. I put a default expression for the field in the table structure and also have that field as a Primary index. Well, it seems to be O.K and it's incrementing as I want. BUT this afternoon, I was testing to see what happens when two users opens the database/Table at about the same time to add records. I noticed that both users Work Order No. fields contains the same entries (I suppose 'cos the RECNO() presented to both users are the same). Although they can both have the same values in the wk order field only one can save because of the primary key nature of the field. My problem seems to be how to get different users enter data into the same database with different work order numbers.
>any idea???
>Please help!!! I would be grateful...

First I wouldn't suggest recno() as a PK. Assuming still you want it :
-Table where recno() is taken should be a another table.
-Whenever you want to take recno(), lock the table, get your recno() and release lock.
-For multiple tables, instead of just getting a recno(), keep an id at that particular table, for each of the tables, ie:
Table_id, Lastrecno
mycustomer 12
myorders 23
...
You can see an example for this in solutions.app and tastrade.app (Both can be find in help\sample applications).
-When you will get the recno() or id, lock the record or table. To prevent and endless lock attempt, "set reprocess to 1", try lock, if not locked continue trying lock with some delay.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform