Updating record I/O files

The fupdate() function, a z/OS® XL C/C++ extension to the SAA C library, is used to update records in a VSAM file. For more information on this function, see z/OS XL C/C++ Runtime Library Reference.
  • KSDS, ESDS, and RRDS

    To update a record in a VSAM file, you must perform the following operations:

    1. Open the VSAM file in update mode (rb+/r+b, wb+/w+b, or ab+/a+b specified as the required positional parameter of the fopen() function call and type=record).
    2. If the file is not already positioned at the record you want to update, reposition to that record.
    3. Read in the record using fread().

      Once the record you want to update has been read in, you must ensure that no reading, writing, or repositioning operations are performed before fupdate().

    4. Make the necessary changes to the copy of the record in your buffer area.
    5. Update the record from your local buffer area using the fupdate() function.

      If an fupdate() fails, you must reposition using flocate() before trying to read or write.

    Notes:
    1. If a file is opened in update mode, a read operation can result in the locking of control intervals, depending on shareoptions specification of the VSAM file. If after reading a record, you decide not to update it, you may need to unlock a control interval by performing a file positioning operation to the same record, such as an flocate() using the same key.
    2. If fupdate() wrote out a record the file position is the start of the next record. If the fupdate() call did not write out a record, the file position remains the same.
  • KSDS and KSDS PATH

    You can change the length of the record being updated. If your request does not exceed the maximum record size of the file, fupdate() writes a record of the length requested and returns the request. If your request exceeds the maximum record size of the file, fupdate() writes a record that is the maximum record size, sets errno, and returns the maximum record size.

    You cannot change the prime key field of the record, and in KSDS AIX®, you cannot change the key of reference of the record.

  • ESDS

    You cannot change the length of the record being updated. If the size of the record being updated is less than the current record size, fupdate() updates the amount you specify and does not alter the data remaining in the record. If your request exceeds the length of the record that was read, fupdate() writes a record that is the length of the record that was read, sets errno, and returns the length of the record that was read.

  • ESDS PATH

    You cannot change the length of the record being updated or the key of reference of the record. If the size of the record being updated is less than the current record size, fupdate() updates the amount you specify and does not alter the data remaining in the record. If your request exceeds the length of the record that was read, fupdate() writes a record that is the length of the record that was read, sets errno, and returns the length of the record that was read.

  • RRDS

    RRDS files have fixed record length. If you update the record with less than the record size, only those characters specified are updated, and the remaining data is not altered. If your request exceeds the record size of the file, fupdate() writes a record that is the record size, sets errno, and returns the length of the record that was read.