Advertisement
Guest User

Untitled

a guest
May 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.54 KB | None | 0 0
  1. drop procedure if exists Payments;
  2. delimiter |
  3. create procedure monthlyTaxPayment(in accountID int, in taxAmount double)
  4. begin
  5. start transaction;
  6. update accounts set amount = amount - taxAmount where accounts.id =
  7. accountID;
  8. if((select amount from accounts where accounts.id=accountID)<0)
  9. THEN
  10.         begin
  11.             insert into debtors
  12.             select customer_id from accounts
  13.             where accounts.id=accountID;
  14.             rollback;
  15.         end;
  16.          else
  17.         begin
  18.             set result = 1;
  19.             commit;
  20.         end;
  21.     end if;
  22. end;
  23. |
  24. delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement