Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.32 KB | None | 0 0
  1. CREATE OR ALTER PROC usp_DepositMoney (@accountId INT, @depositAmount DECIMAL(15, 4))
  2. AS
  3.   BEGIN TRANSACTION
  4.   UPDATE Accounts
  5.   SET Balance += @depositAmount
  6.   WHERE Id = @accountId
  7.  
  8.   IF (@@ROWCOUNT <> 1)
  9.     BEGIN
  10.       ROLLBACK;
  11.       RAISERROR ('Invalid account!', 16, 1);
  12.       RETURN;
  13.     END
  14.  
  15.   COMMIT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement