Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Updation of file from multiple users

Updation of file from multiple users

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.

RE: Updation of file from multiple users

>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.

RE: Updation of file from multiple users

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,

RE: Updation of file from multiple users

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.

Quote (re-designing the application)

Can you suggest any other way I could do that .

RE: Updation of file from multiple users


Quote ((I assume you already have used the primary index tag type for the primary key of your tables)

Yes, I have primary index tag for adata table

RE: Updation of file from multiple users

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close