The update operation allows you to change an existing database record in a logical or physical file.
The UPDAT statement in the RPG/400® language and the REWRITE statement in the COBOL/400® language are examples of this operation. Before you update a database record, the record must first be read and locked. The lock is obtained by specifying the update option on any of the read operations listed under the Read database records using an arrival sequence access path or Read database records using a keyed sequence access path.
If the update operation changes a key field in an access path for which immediate maintenance is specified, the access path is updated if the high-level language allows it. (Some high-level languages do not allow changes to the key field in an update operation.)
If you request a read operation on a record that is already locked for update and if your job is running under a commitment control level of *ALL or *CS (cursor stability), then you must wait until the record is released or the time specified by the WAITRCD parameter on the create file or override commands has been exceeded. If the WAITRCD time is exceeded without the lock being released, an exception is returned to your program and a message is sent to your job stating the file, member, relative record number, and the job which has the lock. If the job that is reading records is not running under a commitment control level of *ALL or *CS, the job is able to read a record that is locked for update.
If the file you are updating has an update trigger associated with it, the trigger program is called before or after updating the record.
If the files being updated are associated with referential constraints, the update operation can be affected.