File Locking

The IBM i system allows a lock state (exclusive, exclusive allow read, shared for update, shared no update, or shared for read) to be placed on a file used during the execution of a job. Programs within a job are not affected by file lock states. A file lock state applies only when a program in another job tries to use the file concurrently. The file lock state can be allocated with the CL command ALCOBJ (Allocate Object). For more information on allocating resources and lock states, refer to the DB2 Universal Database for iSeries section of the Database and File Systems category in the i5/OS Information Center at this Web site - http://www.ibm.com/systems/i/infocenter/.

The IBM i system places the following lock states on database files when it opens the files:

File Type Lock State
Input Shared for read
Update Shared for update
Add Shared for update
Output Shared for update

The shared-for-read lock state allows another user to open the file with a lock state of shared for read, shared for update, shared no update, or exclusive allow read, but the user cannot specify the exclusive use of the file. The shared-for-update lock state allows another user to open the file with shared-for-read or shared-for-update lock state.

The RPG program places an exclusive-allow-read lock state on device files. Another user can open the file with a shared-for-read lock state.

The lock state placed on the file by the RPG program can be changed if you use the Allocate Object command.



[ Top of Page | Previous Page | Next Page | Contents | Index ]