Re: Universal Server - Row Locking Problem
Posted in 1998
Yes, this is a classic one!
THe problem is that you don't have an index on this table. As you issue the
second update statement, IUS starts looking for a record with col_id = 2. As
no index is available, it just starts looping through all the records until
it finds the right one. Because the row you updated with the first statement
was also the first row inserted into the table, it will find that one first
and try to evaluate the condition 'col_id = 2'. However, the row is locked
by some other session, hence the error message.
If you don't believe this: change the first update to 'col_id = 2' and the
second one to 'col_id = 1'. Now things will work fine!
Relational theory says something about 'Physical Data Independency' which
means that the precense or absence of indexes, mirroring and stuff should
not affect the behaviour of your programs. If only theory would be
reality....
Frido
>create table tab1 (
> col_id integer not null,
> col_descn varchar(72),
> primary key (col_id) constraint tab1_pk
> ) lock mode row;>
>insert into tab1 values (1,'First one.');>
>insert into tab1 values (2,'Second one.');>
>First Session:
>
>begin work
>update tab1 set col_descn = 'Changed first one.' where col_id = 1;>
>
> update tab1 set col_descn = 'Changed second one.' where col_id = 2;