On Monday, September 30, 2013 2:52:56 PM UTC-7, Marcel van Pinxteren wrote:
>
> :D
> May I give an exercise to the writer, then.
> To build real optimistic concurrency functionality, the UPDATE query 
> should be something like:
> UPDATE Order SET OrderQty = 1 WHERE OrderID = 123 AND TimeStamp = <8 bytes>
> If someone else has made a change to the record, the update would fail (no 
> records updated), because the WHERE returns 0 records (because the 
> TimeStamp field has changed in the meantime).
>
> Is this something that can be done in Sequel? Removing the column, as you 
> suggested, would certainly not work.
>

This is basically how Sequel's optimistic_locking plugin works, though it 
uses a simple counter and not a timestamp and doesn't remove the value from 
the SET clause.  You should be able to copy the plugin and make a small 
modification to it to work with your database (which updates the column 
automatically).  You'll probably also want to refresh after updating, 
otherwise saving twice in a row may fail.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to