TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)

Chapter 4 107
Using the Database
Reading the Data
During directed access the calling program specifies a record number or address. If any
entry exists at this address, TurboIMAGE/XL returns the values for the data items
requested in the calling program's buffer. If no such entry exists, the program is notified by
an exceptional condition return, such as end-of-file, beginning-of-file, or no entry.
This access method can be used with any type of data set and is useful in situations where
the calling program has already determined the record number of the entry to be read. For
example, if a program surveys several entries using another access method to determine
which one it wants to use in a report, it can save each record number and use the record
number of the entry it selects to read the entry again using the directed access method.
If a program performs a directed read of record 3 of the INVENTORY data set, the entry
marked with a hollow arrow in Figure 4-2. is read. If a directed read of the SUP-MASTER
data set record 7 is performed, the entry in that set marked with the same type of arrow is
read.
NOTE
When using directed access with master data sets, you should be aware of
migrating secondaries. These are described in chapter 10.
Locking. If concurrent users are allowed to add to or delete from a data set, locking
should be used during the search and report sequence to ensure the record numbers do not
change before they are used. In this type of application, a data set lock is usually the most
appropriate.
Serial Access
In this mode of retrieval, TurboIMAGE/XL starts at the most recently accessed storage
location for the data set, called the current record, and sequentially examines adjacent
records until the next entry is located. Data items from this entry are returned to the
calling program, and its location becomes the current record.
You can use both forward and backward serial access. Forward serial access consists of
retrieving the next greater-numbered entry, and backward serial access consists of
retrieving the previous lower-numbered entry. If no entry is located, TurboIMAGE/XL
returns an end-of-file if requested access is forward, or a beginning-of-file if it is
backwards.
Because no current record exists the first time a program requests an entry from a data
set, a request for forward serial access causes TurboIMAGE/XL to search from record 1.
Similarly, a backward serial retrieval begins at the highest numbered record.
The entries connected by curved arrows in Figure 4-2. are read by a program using the
serial access method. If a forward serial read is performed on the INVENTORY data set
before any other type of read, the entry in record number 2 is read. If another forward
serial read is performed on the same data set, the entry in record 3 is read. On the other
hand, if a serial read is performed and the current record is 6, the entry in record 9 is read.
The next forward serial read returns an end-of-file.
The serial access method can be used with any type of data set and is very useful if most or
all of the data in the data set is to be retrieved, for example, to be used in a report. It is
efficient to retrieve all the data in a serial manner, copy it to a file, and sort it with routines
external to TurboIMAGE/XL before printing the report. The availability of serial access