The following figure illustrates a direct data set.
Direct Data Set Description
Records in direct data sets are stored in order by key value. One unsigned numeric data item in the record is designated as the key item; its value is the file-relative record address.
![]() |
For sectioned direct data sets, each section is assigned a base value corresponding to the lowest key value for that section. Records in that section are assigned their relative record address by subtracting the base value for the section from the key item value. |
The POPULATION option of a direct data set refers to the maximum record key value or relative record address instead of the maximum number of valid records. The maximum record key value or relative record address is used to determine the maximum size of the direct data set. The POPULATION option cannot be specified for sectioned data sets.
For example, if POPULATION = 200 and you attempt to add a record with a key value of 201, a limit error results, even if it is the only record.
Direct data sets have two file format levels as follows:
-
Level 0
In this case, no system control information is stored in the file. The end of file is always on a block boundary. Record 0 is not used for data or control information. The DATAEOF value is derived from F.LASTRECORD.
A level 0 file format is used for normal direct data sets.
-
Level 1
In this case, a preallocated structure uses word 0 of block 0 to contain a DATAEOF value. The value is a full-word, binary value that gives the end-of-file value and always points to a block boundary.
A level 1 file format is used for preallocated direct data sets. Preallocation of sectioned direct data sets is not allowed. (Refer to the Enterprise Database Server Utilities Operations Guide for more information on preallocation.)
Direct Data Set Restrictions
The following restrictions apply to direct data sets:
-
Bit vectors cannot be declared.
-
Variable-format records are not allowed.
-
Direct data sets must not be embedded.
-
Each direct data set must have a single Access. Its key item must be a single unsigned number not exceeding 11 digits, or a single group item with subitems of the form NUMBER(n) not exceeding 11 digits in total.
-
Duplicate records on the direct key are not allowed.
The restrictions on the direct data sets are for the following reasons:
-
Disk space utilization is extremely efficient if key values are relatively contiguous. If there are gaps in the allocated key values, a record space is wasted for every unused value. Large gaps waste substantial amounts of space.
![]() |
The amount of wasted space caused by large gaps in key values can be reduced substantially by using sectioning. Use the SECTIONS option to place gaps in the key values at the end of a section or in separate and essentially unused sections. |
-
Record creation, deletion, and modification are extremely efficient. Records are deleted by placing a value other than the proper address in the key field. Reallocation is trivial.
Space for records can be allocated in two different ways. If a record is stored beyond the current end of file, the file is extended to that point with blocks of null records. If desired, the DMUTILITY utility can be used to allocate the space in advance with the INITIALIZE option. In that case, a record stored beyond the DATAEOF value but before the end of file causes the DATAEOF value to be updated. Storage of new records in the existing part of the file—either the part created by normal stores or the part created by preallocation—is more efficient. No duplicate records are permitted; the user receives an exception when attempting to store a second record with the same direct key.
-
The FIND NEXT and FIND PRIOR operations can be used to access the data set in order by key. Valid records are identified by having their key fields equal to their addresses. Since several null records can be examined before a valid record is found, the block size of the file affects the performance of this operation. The FIND NEXT and FIND PRIOR operations initiated by the Access operate exactly the same way, returning records in key order.
-
A FIND AT operation, initiated by the Access, uses the key to directly address the proper record and is very fast.