Take the 2-minute tour ×

I am using Propel as my ORM.

I need to do a batch update to a table with the following fields:


The update will take in an array of Company and set the Assigned field to 1.

The issue is there might be 2 batch updates that occur at the same time. So when that happens, I will have to accept one update, and reject another. Is there anyway to lock the table for one batch update? Or is there a better solution?

share|improve this question
perhaps this will help: markmail.org/message/4g6l6jmji6t66sry –  Sam Saffron Aug 3 '09 at 8:37
@Sam, I am quite skeptical about the solution proposed in your link; it seems that the solution proposed is to add a field and check whether the field is occupied. However, the underlying field in the database is not touched at all. Meaning if the user instantiate a new object in a different call, the field is still false. It doesn't solve the problem –  Graviton Aug 3 '09 at 8:56
add comment

1 Answer

up vote 1 down vote accepted

Here's the solution I found.

Instead of locking it, a better way is to use the following equivalent query when doing the batch update

update table 
set Assigned=2
where Assigned=1
and Company in {company1, company2}

Now, if the number of rows returned is not the same as the number of Company selected, then the whole operation should be rolled back.

share|improve this answer
add comment

Your Answer


