September 30, 2009 at 8:49 pm
I have a stored procedure that updates a row. Here is the problem. A web form has text fields : name, born, died and populates each field with data from the database accordingly. When the update button is pressed it performs the stored procedure, thereby updating the info. But what if two people are on the form at the same time and see the same information. Person 1 changes the name only, but Person 2 changes the "born" only. Person 2 submits ahead of Person 1, thereby changing the "born" value to the newer value, but when Person 1 submits behind Person 2, the name updates, but the "born" will update back to the original date, thereby correcting Person 2's update.
What can I do to make sure that person 1 doesn't overwrite person 2? How can I make sure each update is updated to the new value (i.e. the name gets Updated by Person 1, year born is also updated by Person 2 without them overwriting each other.)
I read somewhere about locks, but I have no clue how to use them in this situation. Expert help is appreciated. And please explain clearly and a step by step approach. I am still rather new to advanced sql problems. Or if possible, direct me to an article.
Any help would be greatly appreciated.
September 30, 2009 at 11:24 pm
It's a big complicated subject with many options. Anything I would write here wouldn't be any better than what's in Books Online. I recommend looking up "row versioning [SQL Server]" (without the quotes) in Books Online where you can explore all the different methods to institute the proper locking mechanisms without making a table unusable or overwriting data in an undesirable manner.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply