From: | Douglas McNaught <doug(at)mcnaught(dot)org> |
---|---|
To: | Fernando Grijalba <fgrijalba(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Help with inventory control |
Date: | 2005-09-30 17:03:39 |
Message-ID: | m2irwixzbo.fsf@Douglas-McNaughts-Powerbook.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Fernando Grijalba <fgrijalba(at)gmail(dot)com> writes:
> Thank you for your response.
>
> I want to avoid the following situation.
>
> User1 starts order and takes the last two units. User2 starts order 1
> minute after and checks inventory. He sees 2 units left and adds them to
> the his order. User1 commits his order. Now User2 cannot finish his
> order because the products are not available anymore.
>
> This is the problem I want to avoid. Therefore if User1 takes the product
> but does not finish the order I want the inventory to still show that the
> product is sold out to other users.
>
> Any suggestions on how to implemnt that?
I think just using SELECT FOR UPDATE should solve this problem--it
will lock the row and SELECT FOR UPDATE in the second transaction
won't return until the first transaction commits.
-Doug
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Nolan | 2005-09-30 19:19:00 | Re: Help with inventory control |
Previous Message | Fernando Grijalba | 2005-09-30 16:45:30 | Re: Help with inventory control |