Does Stardog support something like optimistic locking

see also https://stackoverflow.com/questions/45944181/optimistic-locking-or-conditional-update

Günter,

Optimistic locking is implemented by the application, not by Stardog, so it’s certainly possible. You can express it in SPARQL like so:

DELETE {
  :foo :hasProp ?p ; :hasVersion ?v
}
INSERT {
  :foo :hasProp "newProp" ; :hasVersion ?newVersion
}
WHERE {
  BIND(3 as ?v)
  BIND(4 as ?newVersion)
  :foo :hasProp ?p ; :hasVersion ?v.
}

If you execute this query on the data given in your question, it will change the hasProp and hasVersion values to “newProp” and 4 respectively. However, if you execute it again, it will not change anything because the where clause only matches when the current version is 3 (but it’s now 4).

Hope this helps.

Jess

Excellent!
That was what I was looking for, but I still have troubles formulating my own update queries.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.