Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updation of file from multiple users

Status
Not open for further replies.

Tusk bloom

Programmer
Jul 24, 2017
3
IN
Hello everyone,
I have a report which I prepare before hand. Updation for last modified records takes just before user presss enter to view report and modified records are marked as updated.if 2 user presses enter exactly at the same time, records get append 2 times although I have scanned for the record whose marking is space. How can I remove this duplication problem.
 
>if 2 user presses enter exactly at the same time, records get append 2 times although I have scanned for the record whose marking is space.

Without code it's hard to understand what this means in your case, especially what you mean with "marking is space".

Checking for anything, like field=="" or empty(field) or isrlocked() is giving you an information, that can already be outdated the next moment, so the only really helpful thing to prevent doubles is locking (what rlock() returns is your locking state) and defining a candidate index on fields you want unique (I assume you already have used the primary index tag type for the primary key of your tables).

Bye, Olaf.
 
It sounds as though you want to 'fix' a problem that is in reality being caused by the initial application design in the first place.

Maybe instead of focusing on how to 'fix' the problem now with 'as is' code, it is time to think about re-designing the application from the start - taking into account the possibility that 2 user MIGHT press Enter exactly at the same time.

As Olaf has already indicated, without seeing code, we cannot know why new records are being appended when running a Report - which is generally merely passively reporting on existing data, not causing the entry of new data (assumed by your saying: records get append 2 times).

Keep in mind that I am totally guessing here but perhaps separating out the two operations:
1) Entering new data​
2) Running the Report​
into 2 completely separate operations might be something to consider.

Good Luck,
JRB-Bldr
 
What exact scnerio is I have 1 data table - "Adata"(having field c(1) as Mark) in which entry is done and 1 report which uses data from "Adata" to show report. As report takes time to prepare, so I have kept 1 table say "Rtable" ready so that I need not to process records again and again.

When users add/edit records in adata table, I replace mark field with ' ' . Only newly added/edited records have mark = '' since last time the report was run. So I have to process that many records. Now when any users clicks to view report, all records with mark = '' are processed one by one and adata's mark field is replaced with 'Y'. I can't have primary key in Rtable as for each record of Adata, there are 4-5 records appended in rtable. Now, if 2 users click exactly at the same time, records in rtable gets doubled i.e. say for id 10 of adata , I get 2 set of repeated data one after the other for id = 10 . Shall I lock the adata record which is currently updated so that other user checks isRLocked() status. I have just check whether mark = '' or not.

Can you suggest any other way I could do that .

 
It's still too vague to me, what the data in rtable reflects, why this is appended and how it is related by which way, if you only have one field, that couldn't even be done by a foreign key relation.

If you want to prevent two users using rtable, FLOCK it. And no, testing isrlocked is just the same as checking for a certain value. If things happen almost simultaneous, the state of a lock can change as fast as the change of data can be right after you read a still empty fields value. So that info is useless.

As far as I understand the process you could even FLOCK the DBF, meaning a file lock on the whole file, not only single rows. If that gives you a .T. as return value you know you have the lock, others will fail to add or update records until you unlock.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top