Locking records

 

DB2 Universal Databaseā„¢ for iSeriesā„¢ has built-in integrity for records.

Here is an example of built-in integrity for records. If PGMA reads a record for an update operation, it locks the record. Another program cannot read the same record for an update operation until PGMA releases the record, but another program can read the record just for inquiry.

In this way, the system ensures the integrity of the database. However, you can set your own wait time for a locked record to be released using the WAITRCD parameter.

The system determines the lock condition based on the type of file processing specified in your program and the operation requested. For example, if your open options include update or delete, each record read is locked so that any number of users can read the record at the same time, but only one user can update the record.

The system normally waits a specific number of seconds for a locked record to be released before it sends your program a message that it cannot get the record you are requesting. The default record wait time is 60 seconds; however, you can set your own wait time through the WAITRCD parameter on the create and change file commands and the override database file command. If your program is notified that the record it wants is locked by another operation, you can have your program take the appropriate action (for example, you can send a message to the operator that the requested record is currently unavailable).

If the record lock is being implicitly acquired as a result of a referential integrity CASCADE DELETE, SET NULL, or SET DEFAULT delete rule, the lock wait time is limited to 30 seconds. The system automatically releases a lock when the locked record is updated or deleted. However, you can release record locks without updating the record. For information about how to release a record lock, see your high-level language topic collection.

Using commitment control changes the record locking rules.

You can display locked records using either the Display Record Locks (DSPRCDLCK) command or iSeries Navigator.

 

Parent topic:

Locking shared data

 

Related concepts


Commitment control
Displaying locked records using the Display Record Locks (DSPRCDLCK) command

 

Related tasks


Displaying locked rows using iSeries Navigator