I have a table that stores orders. This table has a field (bProcessed - bit) that records whether the order has been processed (1) or not (0). Ideally, I'd like to update that field to a 1 when I've selected that record to be processed. If I was processing one order at a time, this would be simple, but we are batching these. So I could process 5, 10, 200 orders at one time.
My concern is that doing two statements (one to select, and another to update) may cause incongruent results. Someone could, potentially, place an order slipping between the two statements.
I do have a timestamp on the order, so one solution might be to simply limit the results to a certain date/time range, but is there a better way to do this (to select, and immediately update that selected record to change that bProcessed flag)?
Thanks!