Evan,
The row is locked between the select and update :)
Well, you could still argue that the update still performs better and I have to agree
with you!

Thank you
Regards
Sachin

Evan Ireland wrote:

> Sachin Hardas wrote:
> >
> > Evan,
> > We already do something of that sort. I don't know which is more efficient.
> > When an update is issued, we fetch the record from the database and compare it with
> > the original state we have with us.
>
> There is a small window between your select and update in which time
> the underlying data can be changed. I suggest the modified update syntax
> as it doesn't have any 'windows' where problems can arise.
>
> > A rollback is done if the states don't match.
> >
> > Thank you
> > Regards
> > Sachin
> >
> > Evan Ireland wrote:
> >
> > > Sachin Hardas wrote:
> > > >
> > > > Kristofer,
> > > > The solution you suggested would work only if you can modify the database.
> > > > We are not so lucky and cannot in any way update the database schema.
> > >
> > > Say you have table T, key column K, and data columns X, Y and Z. In your
> > > entity bean for T, save the original values of X, Y and Z. When you issue
> > > an update, use SQL of the form:
> > >
> > >     update T set X = newX, Y = newY, Z = newZ
> > >         where K = theK and X = oldX and Y = oldY and Z = oldZ
> > >
> > > Check the row count for this update. If it is zero, then rollback the
> > > transaction.
> > > ________________________________________________________________________________
> > >
> > > Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
> > >                             Wellington, New Zealand               +64 4 934-5856
> > >
> > > ===========================================================================
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff EJB-INTEREST".  For general help, send email to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> >
> > ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff EJB-INTEREST".  For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> --
> ________________________________________________________________________________
>
> Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
>                             Wellington, New Zealand               +64 4 934-5856
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to