A method for optimistic locking. An integer column is added to a database
table. A Structured Query Language statement is constructed and prepared
to form a prepared Structured Query Language statement, wherein a result
set of the prepared Structured Query Language statement includes the
integer column. Any required parameter information is set in the prepared
Structured Query Language statement. The prepared Structured Query
Language statement is executed in a database transaction. A unique key
associated with an element of the result set of the prepared Structured
Query Language statement is determined. The row of the database table
that the unique key is associated with is determined. A value in the
integer column of the determined row is determined. The value in the
integer column of the determined row is stored to form a stored value
associated with the unique key, wherein the stored value ceases to exist
when the database transaction ends.