MySQL Forums
Forum List  »  InnoDB

q about concurrency for money transfer
Posted by: sagi mann
Date: March 10, 2012 07:09AM

Hi all,
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;

endif


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...
thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
q about concurrency for money transfer
1762
March 10, 2012 07:09AM


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.