CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Concurrency concern: last write wins - none's awar

Print topic Send  topic

Author Message
gluppi@comune.modena.it
Posted: 02/03/2003, 9:07 AM

Project:
Write a web application with CC 2.0.5 for handling this veeery simple table:

TABLE PERSONS
id
lastname
firstname
phonenr

The number of users of this eaaasy application is unknown (but it's greater than 1), their location is unknown and they don't know each other.

Scenario:
Application has been veeery quickly developed with CC :-)) and made available to the users, so they begin to work with it.

UserA INSERTs 1, Smith, John, (empty)
UserB INSERTs 2, Kent, Clark, 555-98765
...
UserA begins editing Smith's record (he doesn't hit update) but he gets a phonecall from his wife: "Honey, bring some coffee when you come home".
So he leaves the office and goes purchasing the coffee for his sweet beloved.
Meanwhile UserB recalls Smith's record and updates the phone number with "555-12345".
UserA is back at his desk now; he watches at the monitor and he reminds his job so he fills the phone field with "555-44852" and finally updates the record.

What happened?
UserA didn't realize that another user updated John Smith's phone number so UserB's changes ARE LOST!! :-((

At last, my question is: how do I solve this seeerious problem?

Thanks and best regards.
Gianni
feha
Posted: 02/03/2003, 10:15 AM

Do they have to login before editing records?
Is it that You need that records created by particular user should be viewed, edited or inserted by only particular user who is logged in even if they are on the same table ?
Or should users see each others records and edit them but not at the same time ??









feha
[www.vision.to]
gluppi@comune.modena
Posted: 02/03/2003, 11:46 PM

Sure, users have to login before editing and every user can edit anybody else's record.

Gianni
RonB
Posted: 02/04/2003, 12:04 AM

what you are looking for is some kind of table lock when a record is being inserted/updated. Oracle has this kind of support but would be a bit overkill for the application you describe. So here's my idea for a solution.
Before loading the record into the record grid set all the values of the record as session variables. Do a before update event that get's the information for that field, checks the data with the data stored in the session variables => the same? no problem do update =>different? cancel update and alert user that data has changed, show new data and ask if the intended update is still valid.

Ron
gluppi@comune.modena
Posted: 02/04/2003, 12:40 AM

Thank you Ron.

Actually, in order to make the problem plain, I simplified the example: the table has more fields. Among the others, there's also a timestamp field, that is updated with the current timestamp everytime the record is written.

The DBMS I'm using is IBM/DB2.

Gianni
RonB
Posted: 02/04/2003, 1:14 AM

The timestampfield is very useable indeed. All you have to do is load the timestamp into a session variable before displaying the record. In a before update vent query the database for that field and compare the timestamp in the db against the one stored in the session variable. If they are different the record has changed since it was loaded in to the record form. Alert the user.

Ron
gluppi@comune.modena
Posted: 02/05/2003, 2:32 AM

How do I alert the user that the record has changed?

A thing like

if (timestampAreDifferent) {
sMyFormErr = "Record has changed" ;
return ;
}


will display the new data, but won't display any error message.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.