MySQL Forums :: InnoDB :: q about concurrency for money transfer
q about concurrency for money transfer
Date: March 10, 2012 07:09AM
I would like to make a money transfer procedure in a single transaction, but whether to perform or not perform the transaction depends on some value in some view (not table). something like this:
select units from view1 where product = 1;
if units > 0 then
update account set money = money - 10 where account_id = 1;
update account set money = money + 10 where account_id = 2;
how can i make this transactional? I was thinking about "select for udpate" but I don't think it works on views, or at least, I'm not sure which records I should lock... I am concerned about the fact that 'units' may change between the "if" statement and the actual update statement...
I'd appreciate any help...
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.