This chapter covers regional data set organization, data transmission
statements, and ENVIRONMENT options that define regional data sets.
Creating and accessing regional data sets are also discussed.
A data set with regional organization is divided into regions,
each of which is identified by a region number, and each of which
can contain one record. The regions are numbered in succession,
beginning with zero, and a record can be accessed by specifying
its region number in a data transmission statement.
Regional data sets are confined to direct-access devices.
Regional organization of a data set allows you to control the
physical placement of records in the data set and to optimize the
data access time. This type of optimization is not available with
consecutive organization, in which successive records are written in
strict physical sequence.
You can create a regional data set in a manner similar to a consecutive
data set, presenting records in the order of ascending region numbers;
alternatively, you can use direct-access, in which you present records
in random sequence and insert them directly into preformatted regions.
Once you create a regional data set, you can access it by using
a file with the attributes SEQUENTIAL or DIRECT as well as INPUT or
UPDATE. You do not need to specify either a region number or a key
if the data set is associated with a SEQUENTIAL INPUT or SEQUENTIAL
UPDATE file. When the file has the DIRECT attribute, you can retrieve,
add, delete, and replace records at random.
Records within a regional data set are either actual records
containing valid data or dummy records.
PL/I supports REGIONAL(1) data sets. See Table 14 for
a list of the data transmission statements and options that you
can use to create and access a REGIONAL(1) data set.
Table 14. Statements and options allowed for creating and accessing regional data sets
|
File
Declaration1
|
Valid Statements,2 With
Options You Must Include
|
Other Options You
Can Also Include
|
|
SEQUENTIAL OUTPUT
BUFFERED
|
WRITE FILE(file-reference)
FROM(reference)
KEYFROM(expression);
LOCATE based-variable
FROM(file-reference)
KEYFROM(expression);
|
SET(pointer-reference)
|
|
SEQUENTIAL OUTPUT
UNBUFFERED
|
WRITE FILE(file-reference)
FROM(reference)
KEYFROM(expression);
|
|
|
SEQUENTIAL INPUT
BUFFERED
|
READ FILE(file-reference)
INTO(reference);
READ FILE(file-reference)
SET(pointer-reference);
READ FILE(file-reference)
IGNORE(expression);
|
KEYTO(reference)
KEYTO(reference)
|
|
SEQUENTIAL INPUT
UNBUFFERED
|
READ FILE(file-reference)
INTO(reference);
READ FILE(file-reference)
IGNORE(expression);
|
KEYTO(reference) |
|
SEQUENTIAL UPDATE3
BUFFERED
|
READ FILE(file-reference)
INTO(reference);
READ FILE(file-reference)
SET(pointer-reference);
READ FILE(file-reference)
IGNORE(expression);
REWRITE FILE(file-reference);
|
KEYTO(reference)
KEYTO(reference)
FROM(reference)
|
|
SEQUENTIAL UPDATE
UNBUFFERED
|
READ FILE(file-reference)
INTO(reference);
READ FILE(file-reference)
IGNORE(expression);
REWRITE FILE(file-reference)
FROM(reference);
|
KEYTO(reference) |
| DIRECT OUTPUT |
WRITE FILE(file-reference)
FROM(reference)
KEYFROM(expression);
|
|
| DIRECT INPUT |
READ FILE(file-reference)
INTO(reference)
KEY(expression);
|
|
| DIRECT UPDATE |
READ FILE(file-reference)
INTO(reference)
KEY(expression);
REWRITE FILE(file-reference)
FROM(reference)
KEY(expression);
WRITE FILE(file-reference)
FROM(reference)
KEYFROM(expression);
DELETE FILE(file-reference)
KEY(expression);
|
|
|
Notes:
1 The complete file declaration
would include the attributes
FILE, RECORD, and ENVIRONMENT; if you use any of the options KEY,
KEYFROM, or KEYTO, you must also include the attribute KEYED.
2 The statement READ FILE(file-reference);
is equivalent to the statement READ FILE(file-reference) IGNORE(1);
3 The file cannot have the UPDATE
attribute when creating new data sets. |