UPDATE (Modify Existing Record)

Free-Form Syntax UPDATE{(E)} name {data-structure | %FIELDS(name{:name...})}
Code Factor 1 Factor 2 Result Field Indicators
UPDATE (E) name (file or record format) data-structure _ ER _

The UPDATE operation modifies the last locked record retrieved for processing from an update disk file or subfile. No other operation should be performed on the file between the input operation that retrieved the record and the UPDATE operation.

The name operand must be the name of a file or record format to be updated. A record format name is required with an externally described file. The record format name must be the name of the last record read from the file; otherwise, an error occurs. A file name as the name operand is required with a program described file.

If the data-structure operand is specified, the record is updated directly from the data structure. The data structure must conform to the rules below:

  1. If the data-structure operand is specified, the record is updated directly from the data structure.
  2. If name refers to a program-described file (identified by an F in Position 22 of the file description specification), the data structure can be any data structure of the same length as the file's declared record length.
  3. If name refers to an externally-described file or a record format from an externally described database file, the data structure must be a data structure defined from the same file or record format, with *INPUT or *OUTPUT specified as the second parameter of the LIKEREC or EXTNAME keyword.
  4. If name refers to a subfile record format from an externally described display file, the data structure must be a data structure defined from the same file or record format, with *OUTPUT specified as the second parameter of the LIKEREC or EXTNAME keyword.
  5. See File Operations for information on how to define the data structure and how data is transferred between the data structure and the file.

A list of the fields to update can be specified using %FIELDS. The parameter to %FIELDS is a list of the field names to update. See the example at the end of %FIELDS (Fields to update) for an illustration of updating fields.

To handle UPDATE exceptions (file status codes greater than 1000), either the operation code extender 'E' or an error indicator ER can be specified, but not both. For more information on error handling, see File Exception/Errors.

Remember the following when using the UPDATE operation:

See Database Null Value Support for information on updating records with null-capable fields containing null values.

For more information, see File Operations.



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