I have a database table with a Y/N flag in one column. I want to read all records where the flag is ‘N’ and after processing a record, set the flag to ‘Y’ in that record. Is it correct, and reasonable, to do this at the same time, using two separate connections? Or should I read the entire table first and update only after I’m done with the reading? What’s the correct approach to this?
The database involved is Netezza, in case it matters.
You should read first then update. Not asynchronsly. If the “select” part takes a long time, you should consider doing it batches. You can use a separate connections but should be confident you’ve completed your read.