Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE usp_deposit_money(account_id INT, money_amount DECIMAL(19, 4))
- BEGIN
- DECLARE from_account INT;
- SET from_account := (
- SELECT count(*)
- FROM accounts
- WHERE accounts.id = account_id
- );
- START TRANSACTION;
- IF (money_amount < 0 OR from_account = 0) THEN
- ROLLBACK;
- ELSE
- UPDATE accounts
- SET balance = balance + money_amount
- WHERE accounts.id = account_id;
- END IF;
- END;
Add Comment
Please, Sign In to add comment