Records are added only at the end of the data set. Existing records cannot be deleted. If you want to delete a record, you must flag that record as inactive. As far as VSAM is concerned, the record is not deleted. Records can be updated, but they cannot be lengthened. To change the length of a record in an entry-sequenced data set, you must store it either at the end of the data set (as a new record) or in the place of a record of the same length that you have flagged as inactive or that is no longer required.
When a record is loaded or added, VSAM indicates its relative byte address (RBA). The RBA is the offset of this logical record from the beginning of the data set. The first record in a data set has an RBA of 0. The value of the RBA for the second and subsequent records depends on whether the file is spanned and on the control interval size chosen for the file, either manually or automatically. In general, it is not possible to predict the RBA of each record, except for the case of fixed-length records and a known control interval size. For a more detailed description of the internal format of VSAM files, see VSAM Data Formats.
You build an alternate index to keep track of these RBAs. Although an entry-sequenced data set does not contain an index component, alternate indexes are permitted. See Defining Alternate Indexes. Figure 2 shows the record lengths and corresponding RBAs for the data set shown in Figure 1.
Table 1 lists the operations and types of access for processing entry-sequenced data sets.
Operation | Sequential Access | Direct Access |
---|---|---|
Loading the data set | Yes | No |
Adding records | Space after the last record is used for adding records | No |
Retrieving records | Yes (returned in entry sequence) | Yes (by RBA) |
Updating records | Yes, but you cannot change the record length | Yes (by RBA), but you cannot change the record length |
Deleting records | Records cannot be deleted, but you can reuse its space for a record of the same length | Records cannot be deleted, but you can reuse its space for a record of the same length |