Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server Row Locking?
Message
From
19/11/2002 21:32:01
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
SQL Server Row Locking?
Miscellaneous
Thread ID:
00724606
Message ID:
00724606
Views:
40
The code below the line is intended to find the next 'Queued' row in an SQL Server 2000 inbox table, change its status to 'Processing' and then return the primary key to a Visual FoxPro application.

I was a bit confused about the best technique to handle this task. Looks like I could change the SET ISOLATION LEVEL, but I am unsure how to set the LEVEL back (does that happen once the Transaction completes?).

Does the ROWLOCK hint only pertain to INSERTs (read that somewhere)? This code will be used in a high transaction environment and probably under a COM+ environment.

Any feedback on the correct way of handling this task will be appreciated.

===============
CREATE PROCEDURE GetInBoxRows AS
 
CREATE TABLE #QueuedInBoxRows (pk uniqueidentifier)
 
BEGIN TRANSACTION
 INSERT INTO #QueuedInBoxRows
 SELECT TOP 1 pk 
  FROM inbox WITH (HOLDLOCK, ROWLOCK)
  WHERE state = 'QUEUED'
 
 UPDATE inbox 
  SET state = 'PROCESSING'
  WHERE pk IN
      (SELECT pk 
        FROM   #QueuedInBoxRows)
COMMIT
 
SELECT pk FROM #QueuedInBoxRows
 
DROP TABLE #QueuedInBoxRows
Next
Reply
Map
View

Click here to load this message in the networking platform