Triger after update as a solution to debit credits safely

Asked

Viewed 22 times

0

I need to make an interface that guarantees the integrity of the customer’s credit. In PHP, when we use LOCK explicitly in PDO, with LOCK TABLES, when dealing there may be inconsistency, when the same client object, is in several processes related even if indirectly to the action of debiting credits. On the other hand, implicit LOCK, using a TRIGGER, can be safer. Let the bank do the work. It is possible in a Rigger After Update, after updating the credits from the credit table, to do an operation to check if the credits are negative, and in the vase of being, then make a transaction rolback. If possible, how best to do it. I thought I’d do the operation inside a Try block catch and catch the Exception. Somebody help me with that analogy, thank you

  • Can’t do that at Rigger.

  • What would be the best way to do that ? I want to discount the credits. If the resulting credit is less than 0, then I want to rollback that transaction, and then, on the application layer, I treat the error.

  • Make a trial. Pass the parameters to her and she can commit or rollback according to the rules of the business.

  • and I can make a look inside that Reginaldo Rigo ?

  • Yes. You can do just about anything.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.