Hi all,
Am try to set a readwrite lock on a database table, here is the code that I am using in my procedure:
I need to lock the table so that I can read and write to it if necessary, while at the same time preventing anyone else from viewing the table.
The error that I am getting is: "Incorrect Syntax near UPDLOCK".
Mike55
Am try to set a readwrite lock on a database table, here is the code that I am using in my procedure:
Code:
CREATE PROCEDURE dbo.spReserveCredits
@Organization as nvarchar,
@Cost as money,
@Result as bit output
AS
UPDLOCK
DECLARE @Amount as money
SELECT @Amount = Credit
FROM SMS_Credit
WHERE Org_ID = @Organization
if @Cost > @Amount
SET @Result = 0
else
begin
UPDATE SMS_Credit
SET Credit = @Amount - @Cost
WHERE Org_ID = @Organization
SET @Result = 1
COMMIT
end
return @Result
GO
I need to lock the table so that I can read and write to it if necessary, while at the same time preventing anyone else from viewing the table.
The error that I am getting is: "Incorrect Syntax near UPDLOCK".
Mike55