db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Franko" <Franko...@uni.de>
Subject How to retrieve number of affected rows on doUpdate or doDelete?
Date Fri, 04 Jul 2003 21:12:28 GMT

I wonder why doUpdate and doDelete in BasePeer do not return the affected rows.

My problem:
I operate on a table with indepentend threads in different VMs.
Each thread looks for rows to process. When it finds one, the thread should set the "in_process"
boolean to "1".

To make sure that no two processes process the same row I would like to:
1) select the row (in_process has to be FALSE) [e.g. pk_id=4711]
2) do an update on the row: UPDATE table WHERE pk_id=4711 AND in_process=0 SET in_process=1
3) the thread should check the number of updated rows, normally returned by this statement
4) a) 1 row alterd means: success! thread can process the row...
   b) 0 rows altered means: in_process was already set to "1" (by another thread) before the

So I need the affected rows... But how?

Is the only solution to use executeStatement with the correct SQL-Statement?

Best regards,

View raw message