Hello, I create a set of new items for each new user by copying from a table which holds the templates. Then I rename the "dummy" user ID with the real user ID. I pass the real user ID from the application calling the the stored procedure.
THE problem is: what happens if two users create new records at the same time!!!! oh oh oh ...
Here goes the code:
INSERT INTO userTable (userID, TemplateFK, Rating) SELECT UserID, PK as TemlateFK, Rating FROM
UPDATE userTable SET UserID=@userid WHERE UserID=-1
I have set the UserID in the templateTable="-1"; So, all new set of fields per user are inserted with the value="-1"
How could i combine the two lines of code into one? This code will obviously cause problems if two users at the same time create a new set of records...
Many thanks for your help.
View Complete Post