database deadlocks - How to do a safe "SELECT FOR UPDATE" with a WHERE condition over multiple tables on a DB2? -


problem

on db2 (version 9.5) sql statement

select o.id table1 o, table2 x [...] update rr 

gives me error message sqlstate=42829 (the update clause not allowed because table specified cursor cannot modified).

additional info

i need specify with rr, because i'm running on isolation level read_committed, need query block while there process running same query.

solution far...

if instead query this:

select t.id table t t.id in (     select o.id table1 o, table2 x [...] ) update rr 

everything works fine.

new problem

but deadlock exceptions when multiple processes perform query simultaneously.

question

is there way formulate for update query without introducing place deadlock can occur?

first, having isolation level read_committed not need specify with rr, because results in isolation level serializable. specify with rs (read stability) enough.

to propagate for update rs inner select have specify additionally use , keep update locks.

so complete statement looks this:

select t.id table t t.id in (     select o.id table1 o, table2 x [...] ) update rs use , keep update locks 

i made tests on db2 via jdbc , worked without deadlocks.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -