Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Row Locking
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Miscellaneous
Thread ID:
01263435
Message ID:
01265585
Views:
12
Hi Zoran
Thanks. I will give it a go.

Kind Regards,
Fred
>>Hi Guys,
>>I am converting a VFP app to SQL Server Database. This app has stock control and about 50 users use the system simultaneously. A lot of inventory management. I need to use pessimistic locking, So the stock on hand gets incremented or decremented depending on the type of transaction. In VFP I issued a Rlock() on the record, updated and then released it, how do I achieve this in SQL. Any help will be appreceiated.
>>
>>TIA
>
>
>Fred,
>
>The following works fine for me:
>
>BEGIN TRANSACTION
>
>UPDATE
> MyTableName WITH (ROWLOCK) --this will lock all records affected
>SET
> MyColumn = MyColumn + MyNewValue
>WHERE
> PK = MyCondition
>
>--read the UPDATED Content, at this point all other users have to wait
>SELECT MyColumn FROM MyTableName WHERE PK = MyCondition
>
>
>--release the lock
>COMMIT TRANSACTION
>
>
>--Aditionally, you can take a look at "SET TRANSACTION ISOLATION LEVEL" setting on the server
>--Hope this helps
Fred Besterwitch, MCP

The harder you work. The luckier you get.
Previous
Reply
Map
View

Click here to load this message in the networking platform