• Aucun résultat trouvé

REWRITE FILE(F) FROM(A);

Dans le document IBM System/360 Operating System PL/I (F) (Page 71-75)

AUTOMATIC II ALIGNED, AREA 15,17

10 REWRITE FILE(F) FROM(A);

Statement number (10) would cause the ERROR condition to be raised, since between the REWRITE statement and its corresponding READ statement (1), there is an intervening READ statement (5).

When blocked records are used with UPDATE files, it must be remembered that if one record in a block is rewritten, then all the records in that block are rewritten.

The user must take this into account when

updating records obtained by means of READ •••• SET.

INDEXED

£f~~~!on of INDEXED Data Sets

Special DD statement requirements are as follows:

One, two~ or three DD statements are required. The number depends on the sizes and relative positions of the three parts of the INDEXED data set, namely the prime data area, the over-flow area, and the index area. The SPACE and DSNAME fields of the CD caru have special formats for INDEXED data sets.

The following DCB subpararneters mu~~ be specified:

KEYLEN=n DSORG=IS

The following DCB subparameters may be specified:

RKP=n

OPTCD=LIMIYII (or any combination) NTM=n

CYLOFL=n

Space for the data set must

ce

allocat-ed in cylinders, unless the absolute track (ABSTR) technique is used. If ABSTR is used, the number of tracks must be equivalent to an integral num-ber of cylinders, and the first track used must be the first track on a cylinder which is not the first cylin-der on a volume.

Programming considerations are as fol-lows:

For blocked INDEXED data sets, the DCB subparameters LRECL and BLKSIZE must be

sp~cified as follows:

Without embedded key (i.e., RKP=O), LRECL size of data area + size of key

With embedded key (i.e., RKP*O), LRECL = size of data area

In both cases, BLKSIZE blOCking factor.

LRECL x Creation of an INDEXED data set is only available in the SEQUENTIAL OUTPUT mode. The EVENT option is not

support-ed for SEQUENTIAL access to INDEXED .data sets. The LOCATE statement is

only valid for BUFFERED files.

When creating INDEXED data sets, the values of the keys presented must be in ascending collating sequence order;

i.e., the binary value of each succes-sive key must be greater by at least 1 than that of the previously presented key. Therefore, duplicate keys cannot be added to the data set.

Data set specifications made during creation may not be altered during subsequent processing of the data set;

e.g. KEYLEN is fixed during creation.

Also prov1s1on for overflow areas, whether cylinder or independent, must be made when the data set is created.

If the prime data area is not filled during creation, then, with one excep-tion, the unused area is not usable for overflow records, nor for any records subsequently added during direct access. The exception is that the unfilled portion of the last track used may be filled if required. It is possible to reserve space for later use within the prime 1ata area by writing

"dummy" records during creation: pro-vided that the initial byte of the record has the value (8) 11'B, and that the option OPTCD=L has been specified, these dummy records can subsequently be replaced by actual records with the same key.

Refer to the publication 11M System/360

OpeEating_§y~te~L-~QQ_£QQ~E2l Language, and lBM __ §y~te~Ll£Q __ QE~E~~Q~§ystem, Job

Con-~EQ!_~an~~~g~_fh~rt~, for more detailed discussion of the above considerations.

After an INDEXED data set is created, i t may be reopened for INPUT or UPDATE, for either SEQUENTIAL or DIRECT access. If opened for DIRECT access, records may then be added and deleted. It should be noted that once created~ an INDEXED data set may not be opened for OUTPUT to add further records; i t must be opened for UPDATE.

The user is cautioned that only one DIRECT UPDATE file that adds records to an INDEXED data set should be open at anyone time. If two files are simultaneously open for SEQUENTIAL and DIRECT processing of the same INDEXED data set, then the following records might not be accessed by the SEQUENTIAL file:

1. Records added to the end of the data set.

2. Records written directly in the over-flow area of the data set.

3. Records written on the overflow area when forced out of the prime data area by a record being added to this data area.

INDEXED data sets accessed in the SEQUENTIAL fashion may be opened for either INPUT or UPDATE, once created. sequential access is in the order defined by the values of the recorded key, i.e., ascending collating sequence order. Records are retrieved in this order irrespective of the sequence in which they were added to the data set. Those records which have been deleted are not retrieved, and may be overwritten or lost when other records are added to the data set.

It is possible to use the KEY option on READ statements to cause repositioning, in either a forward or backward direction, among the records being sequentially accessed either for INPUT or UPDATE. This facility is available only if the KEYED attribute is specified. Repositioning may be either to a specified record or, if GENKEY has been specified in the ENVIRON-MENT option list, to the first non-dummy record of a particular key class. In either case a record is retrieved followed by the next higher keyed record if the subsequent READ does not have a KEY option.

If the specified KEY is not found in the data set. the KEY condition is raised. A subsequent READ without the KEY option will retrieve the first record in the data set.

The EVENT option is not supported for SEQUENTIAL access to INDEXED data sets.

READ SET and REWRITE without the FROM option are only valid for BUFFERED files.

When opened for SEQUENTIAL UPDATE, only the statements READ and REWRITE (other than OPEN and CLOSE) may apply to the file. The order of operation must be READ then

REW-RITE~ but not every record read need be rewritten. When blocked records are used with UPDATE files, i t must be remembered that if one record in a block is rewritten, then all the records in that block are rewritten. The user must take this into account when updating records obtained by means of READ •••• SET. Records may not be added to the data set when in this mode, but they may be deleted simply by setting the initial character of the record to the delete-code (i.e. a character of the value

( 8 ) l lI B) and then rewriting it. This can also be done by using the DELETE statement

which marks as deleted the last record read. Records which are marked "deleted"

are not made available during sequential input.

If blocked records are to be deleted, RKP must be greater than O. This is necessary because a deleted record is indi-cated by (S)'1'B in the first byte and, for blocked records, this byte is part of the recorded key; hence if RKP=O, the access of subsequent records in the block may be impossible.

After several usages of an INDEXED data set in which records have been added or deleted, i t may become desirable to copy the data set from one volume to another in order to purge the data set of records marked deleted, but still physically pre-sent, and to collect records from overflow areas into the prime data areas. Such reorganization will allow more efficient future access to the data set.

INDEXED data sets accessed in the DIRECT fashion may be opened for INPUT or UPDATE, once created. A DIRECT UPDATE file may have records added, deleted, or replaced, as well as retrieved.

Retrieval of Records: Records marked

"deleted"-are-no~made-available.

:ddition of Records: If the key is unique, the-record-isadded-to the data set, either in the prime area <possibly replacing one marked deleted), or in an overflow area;

indexes are automatically updated as neces-sary. Duplicate keys cause the KEY condi-tion to be raised, as will failure to find available space for the addition of records.

If a new record is added to a data set whose overflow areas are already full, a record will be irretrievably lost. The position of the new record, in relation to the existing records on the track, will determine whether it is the new record or an existing one which is lost. If the new record would follow the last existing record on the track, the new record will be lost. otherwise, the last existing record on the track will be lost. In either case.

the KEY condition will be raised.

Deletion of Records: The specified record ISIocatecr;--marked deleted, and rewritten into the data set. Note that deletion of records is only available if the DCB param-eter of the DD statement specified OPTCD=L.

If blocked records are to be deleted, RKP must be specified as greater than zero.

Otherwise, owing to the technique by which records are marked as deleted -- ty setting the initial byte of the record, which for blocked records includes the recorded key.

to the value (S}"'B -- the locating of subsequent records in the data set may be impossible.

~E1~~~~n~

__

2K--E~£ords~ The specified record is overwritten ty the replacement record. Records may be replaced without having been read, unless the data set contains blocked records, in which case the sequence must be READ then REWRITE. In the case of blocked records, a WRITE, DELETE, or READ statement may not be issued while a previous READ statement is still outstand-ing; that is, before its corresponding REWRITE statement has been issued. The EXCLUSIVE attribute should be specified to synchronize the READ-REWRITE cycle and WRITE statements.

REGIONAL

The three types of organization are treated following paragraphsa

REGIONAL data set together in the

Creation of REGIONAL Data Sets

Special DD statement requirements are as follows:

rhe following DCB subparameters mu~~ be specified:

KEYLEN=n (except for REGIONAL(1}) DSORG=DA

The following DCB subparameters may be specified:

LIMCT=n (except for REGIONAL(1»

Space allocation (via the DD statement parameter SPACE) may be in terms of records, tracks, or cylinders; use of the ABSTR subparameteris permitted also. When allocating space for a REGIONAL data set, i t is possible to request secondary allocation, such that when the initial allocation is filled, a second allocation is automatically made; further allocations are also made when necessary. (Secondary allocation is only available when the data set is being created, and then only when opened for SEQUENTIAL OUTPUT; opening for DIRECT OUTPUT causes the initial

allocation, only, to be "formatted" for direct placement of records.)

Programming considerations are as fol-lows:

Creation of REGIONAL data sets may be performed with either DIRECT or SEQUEN-TIAL access; the mode must be OUTPUT.

~JE~f~_£E~ationL Upon opening the data set, it is initialized in accordance with the record format employed.

F-format. (REGIONAL(1), (2), and (3»:

E~ch track within the initial alloca-tion is initialized with dummy records (and keys, if (2) or (3».

U- and V-format (REGIONAL(3»: Eacn track within the initial allocation is

"cleared" by writing a special record termed the capacity record. This record is set to indicate that the complete track is available for the addition of records.

Creation employing the DIRECT access technique permits records to be placed anywhere within the data set, in any order. Subsequent retrieval of these records in a SEQUENTIAL fashion, howev-er, will access the records in a physi-cally sequential order.

When there is a danger of more than one record having the same recorded key, the DCB subparameter KEYLEN should be increased so that the region number is also recorded; provided that the region number of the two records is not also the same, there will then be no retrie-val problem.

~!QUE~~J~b~feati2~~ Keyed records are presented for addition to the data set according to the following rules.

REGIONAL(1) and (2): The positioning value of the key must increment by at least 1 for each successive key; if the value increments by a value greater than 1, say n, then n - 1 dummy records are added to the data set before the given record is added.

REGIONAL(3): The positioning value of the key remains constant for addition of records to a given track. When switching to a new track is desired, the positioning value is incremented by at least 1. If the value increments by a value greater than 1, say n, then n - 1 intervening tracks are cleared (if formats U or V) or written with dummy records (if format F., in which case the current track is completed with dummy records).

If a LOCATE statement was used in the addition of KEYED records to any type of REGIONAL data set. then, if the RECORD condition is raised, the key value presented at subsequent opera-tions must not be less than the current one.

Creation employing the SEQUENTIAL access techniques causes records to be added to the data set in a physically sequential order, according to ascend-ing relative record or track value.

subsequent retrieval of the data set in a SEQUENTIAL fashion will access these records in the same order (as well as any records which may have been insert-ed between them). When a sequentially created REGIONAL data set is closed, the current extent is completed with dummy records, or the remaining tracks are cleared.

The user is cautioned that, for REGIONAL(3) data sets, the addition of duplicate keys is not detected; subse-quent DIRECT access will read the first record with the required key on the given track (or tracks. if

"extended-search" has been requested, i.e., if the DD subparameter LIMCT is absent or specifies a value greater than one).

Also note that when a given track of a REGIONAL(3) data set becomes filled by sequential addition of records with the same region number (relative track value), the current track number is automatically incremented by 1. If an attempt is then made to add another record with the same region number, the KEY condition is raised (key sequence error) and the excess record is not added to the data set.

After a REGIONAL data set is created, it may be reopened for INPUT or UPDATE, SEQUENTIAL or DIRECT. If opened for DIRECT access, records may then be added or delet-ed. It should be noted that once created, a REGIONAL data set may not be opened for OUTPUT to add further records; i t must be opened for UPDATE.

SEQUENTIAL Access

REGIONAL data sets accessed in the SEQUENTIAL fashion may be opened for either INPUT or UPDATE, once created. sequential

access is in the order of ascending rela-tive record (REGIONAL(1) and (2» or track value; the value of the keys does not affect the order of retrieval. It should be noted that all records within a REGIONAL(1) data--set, whether dummy or actual, are retrieved in sequence; if dummy records are present, the user should be prepared to recognize them if necessary.

Deleted (dummy) records in REGIONAL(2) or (3) data sets are not made available.

It is not possible to employ the KEY option when retrieving REGIONAL data sets sequentially.

~~E!~£em~~~_-2!. __ g~£2fds~ When a REGIONAL data set is opened for SEQUENTIAL UPDATE#

the only IIO statements which may be used, apart from OPEN and CLOSE, are READ and REWRITE. A REWRITE statement may not be issued until a READ statement has been issued; and a REWRITE statement will always update the last record read. It is not permissible to have intervening READ state-ments between a READ and a REWRITE refer-ring to the same record in the data set.

For example:

READ FILE(F) INTO(A);

Dans le document IBM System/360 Operating System PL/I (F) (Page 71-75)

Documents relatifs