February 4, 2003 at 9:41 am
I have a Stored Proc which handles a login, I'm select the MAX ID and returning that if its a new record or Inserting the new row if they dont exist.
Currently I'm getting deadlock problems. The SP has the following IF statement within it:
IF EXISTS(SELECT ID,Email,PW FROM tbl_TEST WHERE Email = @strEmail AND PW = @strPassword)
BEGIN
UPDATE tbl_TEST SET ApplicationType = @strApplicationType, TableType= @strTableType WHERE Email = @strEmail AND PW = @strPassword
SELECT * FROM tbl_TEST WHERE Email = @strEmail AND PW = @strPassword
SET @intReturnVal = 1
RETURN
END
ELSE
BEGIN
SELECT @intMAXID = MAX(ID) + 1 FROM tbl_TEST
INSERT INTO tbl_TEST (
ID,
PW,
)
VALUES(
@intMAXID,
@strPassword,
@strEmail
)
SET @intReturnVal = 0
SET @intNewMaxID = @intMAXID
RETURN
END
The SQL queries all talk to the same table and it is in a flat table. Can you suggest how I update this code to aviod getting Deadlocks?? (Proper use of TRANS ??)
February 7, 2003 at 8:00 am
This was removed by the editor as SPAM
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply