M
Member 310024
Guest
Environment: IMB Z series Mainframe, MVS, COBOL/DB2
DB2 locking has always seemed a bit mysterious to me.
I understand the concept of locking, and if I knew
how to explicitly (manually) lock a record, I would
lock it when I needed it locked.
Is there a DB2 intrinsic that you can call, when you
want to lock a record?
I recently stuffed up when a delete failed with -911.
I selected the primary key (not a cursor) thinking
that if someone else has it, my select would fail.
After the sqlcode was not +100, I then went ahead with
my delete but got a -911 on the delete, which got sent
thru the non zero sqlcode terminate routine.
All the records in the buffer that were awaiting commit,
got committed, (because I didn't say rollback?) which I didn't want.
Is it the attempted delete that I should be checking
for -911, as the means of determining if the record
is already locked by another user?
Is there some way I can determine the lock status
with my non-cursor select of the primary key, and
then if it isn’t, lock it for myself, and when I'm
finished - unlock it?
The locking seems to be automatically done, outside
of my control (is it not?).
Thanks in advance for any comment.
DB2 locking has always seemed a bit mysterious to me.
I understand the concept of locking, and if I knew
how to explicitly (manually) lock a record, I would
lock it when I needed it locked.
Is there a DB2 intrinsic that you can call, when you
want to lock a record?
I recently stuffed up when a delete failed with -911.
I selected the primary key (not a cursor) thinking
that if someone else has it, my select would fail.
After the sqlcode was not +100, I then went ahead with
my delete but got a -911 on the delete, which got sent
thru the non zero sqlcode terminate routine.
All the records in the buffer that were awaiting commit,
got committed, (because I didn't say rollback?) which I didn't want.
Is it the attempted delete that I should be checking
for -911, as the means of determining if the record
is already locked by another user?
Is there some way I can determine the lock status
with my non-cursor select of the primary key, and
then if it isn’t, lock it for myself, and when I'm
finished - unlock it?
The locking seems to be automatically done, outside
of my control (is it not?).
Thanks in advance for any comment.