MIDRANGE dot COM Mailing List Archive



Home » JAVA400-L » October 2005

RE: Locking records in DB2



fixed

> From: Paul Holm
> 
> Update x.y  set name = 'Frank' where keyField = 9 and lockfield1 =
"old
> value1' and lockfield2 = 'old value2'

If you're going to do this, please include the code that checks for lack
of update.  I assume there is some magic field in the SQL return data
that indicates the number of records updated; if that value is zero,
then perform the "record was updated by someone else" logic.

This also gets really cumbersome when there are lots of fields to check.


> b.  Using a counter or timestamp loses this level of control.  An
> unimportant field change could through out a pending change when
really it
> shouldn't have to.

If you have dissociated field groups (whether or not such a database
design is valid is a different discussion for a different day), simply
add one counter for each field group.  If you have data that can be
overwritten, only update the counter if an "important" field is updated.


> In addition, most databases don't have this counter or
> timestamp and folks are resistant to adding a new field to all files
for
> this purpose.

This is not a good reason, especially if you have encapsulated your
updates in a single place.  It only gets to be problematic when you have
database updates littered throughout your application, which is poor
architecture in the first place.

Joe






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact