Note that there are some explanatory texts on larger screens.

plurals
  1. POImplement pessimistic locking
    primarykey
    data
    text
    <p>I'm interested in how I can implement pessimistic locking, with very specific behavior. (The reason I tagged the question with Sybase+Oracle+MSSQL, is because I'd be happy with a solution or "that's impossible!" for any one of them)</p> <p>What I want is this: 1 - be able to lock a row (so that process can later do update, but no other process can lock the row) 2 - when another process tries to lock same row it should get notification that record is locked - I don't want this process to hang (I believe simple timeout can be used here) 3 - when another process tries to read record, it should be able to read it the way it is currently in database (but I don't want to use dirty reads).</p> <p>The above 3 requirements are currently solved by application using shared memory - and performing record-locking outside database. I'd like to move the locking into the database.</p> <p>So far, I'm having conflicts between #1 and #3 - if I lock record by doing 'update ...' by updating a field to same value, than 'select' from another process hangs.</p> <p>Edit: I'm having some luck now with snapshot isolation level on MSSQL. I can do both the locking, and reads without using dirty reads.</p> <p>The reason I don't want to use dirty-reads, is that if a report is running, it might read multiple tables, and issue multiple queries. Snapshot gives me a consistent snapshot of the datatabase. With a dirty read, I'd have mismatching data - if there were any updates in the middle.</p> <p>I think Oracle has snapshot as well, so now I'm most interested in Sybase.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload