Hi,<br /><br />I am trying to provide a simple data entry interface to allow multiple people to efficiently work
throughevery record in a table and fill in the missing values.<br /><br />The interface is a web application that
simplyloads up record after record until they're all complete.<br /><br />I want to minimize the possibility of
assigningthe same record to two users.<br /><br />Below is how I'm thinking of assigning records to clients for
editing. The idea is to pick a record for a user and remove it from the queue temporarily. It re-enters the queue
after5 minutes if no edit has been made.<br /><br />BEGIN;<br />SELECT * FROM records<br />WHERE in_edit_queue AND id
NOTIN (<br /> SELECT record_id FROM locked_records<br /> WHERE locked_since < now() + interval '5 minutes')<br
/>LIMIT1;<br /><br />INSERT INTO locked_records (record_id, locked_since) VALUES (?, now());<br /> COMMIT;<br /><br
/>Thento save (first-in wins is acceptable for this environment):<br /><br />BEGIN;<br />UPDATE records SET
in_edit_queue= false WHERE id = ? AND in_edit_queue = true;<br />DELETE FROM locked_records WHERE record_id = ?;<br />
COMMIT;<br/><br />Is this a sane approach? Is there a better way to do this with PostgreSQL?<br /><br />All feedback
isgreatly appreciated..<br /><br />Cheers,<br />J.<br />