The iSeries database has built-in record integrity. The system
determines the lock conditions that are based on how your ILE C/C++ program
opens the file. This table shows the valid open modes and the lock
states that are associated with them:
Table 15. Lock States for Open Modes
Open Mode | Lock State |
---|---|
r or rb | shared for read (*SHRRD) |
a, w, ab, wb, a+, r+, w+, ab+, rb+, wb+ | shared for update (*SHRUPD) |
You can change the lock state for a file by using the Override Database File (OVRDBF) command or the Allocate Object (ALCOBJ) command before you open the file. For example, your ILE C program can use the system() function to call the ALCOBJ command:
system("ALCOBJ OBJ((FILEA *FILE *EXCLRD))");
If a file is opened for update, the database locks any record read or positioned to provided the __NO_LOCK option is not specified. This means that the locked record cannot be locked to any other open data path, whether that open data path is opened by another program or even by the same program through another file pointer.
Successfully reading and locking another record releases the lock on a previously locked record. If the __NO_LOCK option is specified on any read then the lock on the previously locked record is not released. You can also release a lock on a record by using the _Rrlslck() function.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.