|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Locking selected rows for updatei've got the following problem: For the project i'm in, i have to design a application which is for inputing some data from scanned inventory sheets. There are a number of users, which have to have access to this sheets for type in. I defined a table called WorkStack, which contains the sheets for input. Every user gets his own Stack of Sheets if he does the login (eg 500 sheets). For this, i made a column in the table called currentuser. My approach was, to select 500 rows with the appropriate select statement and store this in list. Now i have to lock the sheets i got. I thought that i simple have to do an UPDATE for each selected row and set the CurrentUser Field to the current user id. The problem is, if i do this, between select and update, another user could get the already selected rows of the first user. So i decided to do the SELECT and UPDATE within a transaction, but this obviously does not the trick. I can still get the already selected sheets of the first user... Probably i'm thinking way to far, but i would be very happy if someone could deliver me with some tip's or patterns to do this action -> SELECT a bunch of rows, and lock it, so no other user can access them while the first user is giving some input... Thanks in advance, Tom Hi
Check this reply to a similar question: http://tinyurl.com/dh45f John <t*@semanticsystem.com> wrote in message Show quote news:1127570821.701380.301250@g44g2000cwa.googlegroups.com... > Hi there, > > i've got the following problem: > > For the project i'm in, i have to design a application which is for > inputing some data from scanned inventory sheets. There are a number of > users, which have to have access to this sheets for type in. > > I defined a table called WorkStack, which contains the sheets for > input. Every user gets his own Stack of Sheets if he does the login (eg > 500 sheets). For this, i made a column in the table called currentuser. > My approach was, to select 500 rows with the appropriate select > statement and store this in list. Now i have to lock the sheets i got. > I thought that i simple have to do an UPDATE for each selected row and > set the CurrentUser Field to the current user id. The problem is, if i > do this, between select and update, another user could get the already > selected rows of the first user. So i decided to do the SELECT and > UPDATE within a transaction, but this obviously does not the trick. I > can still get the already selected sheets of the first user... > > Probably i'm thinking way to far, but i would be very happy if someone > could deliver me with some tip's or patterns to do this action -> > SELECT a bunch of rows, and lock it, so no other user can access them > while the first user is giving some input... > > Thanks in advance, > > Tom > Thank Erland for that!
Show quote "Tom" <t*@semanticsystem.com> wrote in message news:1127573237.697447.172210@z14g2000cwz.googlegroups.com... > Hi John, > > thanks alot, this reply contains exactly the solution! > > Tom > |
|||||||||||||||||||||||