Thanks, Mark.
Is a Commit done automatically when I close the Cursor or do I have to
explicitly issue a commit? My table has a single row with a single column.
The stored value is essentially an incrementing counter that I don't want
read or altered by concurrent requests.
Thanks again.
> > Hi All,
> >
[quoted text clipped - 56 lines]
> are a lot of rows, you can use the "with hold option" and do intermediate
> commits without automatically closing the cursor.
Knut Stolze - 25 Apr 2006 16:07 GMT
> Thanks, Mark.
>
> Is a Commit done automatically when I close the Cursor or do I have to
> explicitly issue a commit? My table has a single row with a single
> column. The stored value is essentially an incrementing counter that I
> don't want read or altered by concurrent requests.
The end of a transaction (commit or rollback) is completely independent of
cursors. So you have to use your own explicit COMMIT statement (or the
respective API call). Where a connection does exist is that all cursors
are closed at ROLLBACK and non-holdable cursors are closed at COMMIT
(holdable cursors are kept open after the commit).

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany
Mark A - 25 Apr 2006 18:36 GMT
> Thanks, Mark.
>
[quoted text clipped - 5 lines]
>
> Thanks again.
This is a common situation. The following is the best solution and will
avoid deadlocks:
-- increment the sequence number and hold exclusive lock on the row
UPDATE sequence_table
SET seq_number = seq_number + 1
WHERE seq_key = ?;
-- to retrieve the value you just incremented above
SELECT seq_number
FROM sequence_table
WHERE seq_key = ?;
COMMIT;