Locking
The IBM® i 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:
| 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) |
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.