Reputation: 1671
There are similar questions asked here, but was not able to find something close enough to actually resolve my problem as they involve multiple tables. So here goes...
I need to select a recordset for processing. To prevent parallel processing from selecting the same records, I want to set a status flag in the record that I can use to exclude those records on subsequent calls, i.e.
SELECT ... WHERE statusflag <> 1 //(or whatever)
I know I could use a transaction and SELECT FOR UPDATE, spinning through those records updating the flag, but I was hoping to accomplish both tasks (get/update) with one database hit. Is this possible in MySQL?
Upvotes: 0
Views: 695
Reputation: 60047
You need to use cursors in a stored procedure. There are a few tutorials on-line that will help you.
Upvotes: 2