• Aucun résultat trouvé

output buffer for a based variable, setting a pointer to the location in the buffer as

Dans le document PL/I System/360 (Page 121-124)

i t does so. This pointer can then be used to refer to the allocation so that data can be moved into the buffer. The record is written out automatically. during execution of a subsequent WRITE or LOCATE statement for the file, or when the file is closed.

~hapter

10: Record-Oriented Transmission 117

The DELETE Statement

The DELETE statement specifies that a record in an UPDATE file be deleted. (The implementation does not erase the record when a DELETE statement is executed, but flags i t as "deleted.")

The UNLOCK Statement

The UNLOCK statement does not cause data to be transmitted, but is used to unlock a record in an EXCLUSIVE DIRECT UPDATE file.

When a record is read from a DIRECT UPDATE file, i t may subsequently be rewritten or

d~leted to complete the updating operation:

i f the file is EXCLUSIVE, the read

operation automatically locks the record to prevent interferenqe by other tasks during this process. The UNLOCK statement makes the specified record available to tasks other than that for which the locking READ statement was issued: i t therefore provides an alternative means of completing the updating operation .•

For further information see "Sharing Files between Tasks" in Chapter 15.

OPTIONS OF TRANSMISSION STATEMENTS 0

Options that are allowed for record-oriented data transmission statements differ according to the attributes of the file and the

characteristics of the associated data set.

Lists of all of the allowed combinations for each type of file are given in Figures 10-5, 10-6, and 10-7, later in this

chapter.

Each option consists of a keyword followed by a value, which is a file name, a variable, or an expression. This value must always be enclosed in parentheses. In any statement, the options may appear in any order.

The FILE Option

The FILE option must appear in every record-oriented statement. It specifies the name of the file upon which the

operation is to take place. It consists of the keyword FILE followed by the file name enclosed in parentheses. An example of the FILE option is shown in each of the

statements in this section.

118

The INTO Option

The INTO option can be used in the READ statement for any INPUT or UPDATE file.

The INTO option specifies a variable to which the logical record is to be assigned.

READ FILE (DETAIL) INTO (RECORD_l);

This specifies that the next sequential record is to be assigned to the variable RECORD_1.

Note that the INTO option can name an element string variable of varying length;

thus i t is possi~le to read a record whose length is unknown to the PL/I programmer, and is not contained in the data. The current length of the string is set to the length of the record.. The LENGTH built-in function can be used to find the length of the record.

When the record variable of a READ statement is a variable length bit~string,

the byte count" and not the bit count, is stored as the current length,. This is an implementation restriction because all variable length bit-strings are not both byte aligned and multiples of eight.

The FROM Option

The FROM option must be used in the WRITE statement for any OUTPUT or DIRECT UPDATE file. It can also be used in the REWRITE statement for any UPDATE file. The FROM option specifies the variable from which the record is to be written. If this

variable is a string of varying length, the current length of the string determines the size of the record.

For files other than DIRECT UPDATE or SEQUENTIAL UNBUFFERED UPDATE files, the FROM option can be omitted from a REWRITE statement.. If the last record was read by a READ sta tement with the INTO option, REWRITE without FROM has no effect on the record in the data set; but if the last record was read by a READ statement with the SET option, the record will be updated, in the buffer, by whatever assignments were made.

WRITE FILE (MASTER) FROM (MAS_REC);

REWRITE FILE (MASTER) FROM (MAS_REC):

Both statements specify that the value of the variable MAS REC is to be written into the file MASTER.- In the case of the WRITE statement, i t specifies a new record in a SEQUENTIAL OUTPUT file. The REWRITE

statement specifies that MAS REC is to replace the last record read-from a SEQUENTIAL UPDATE file.

The SET' . Option

The SET option can be used with a READ statement or a LOCATE statement. It specifies that a named pointer variable is to be set to point to the location in the buffer into which data has been moved during the READ operation, or which has been allocated by the LOCATE statement.

READ FILE (LIST) SET (P);

This statement specifies that the value of the pointer variable P is to be set to the location in the buffer of the next

sequential record.

The.IGNORE·Option

The IGNORE option can be used in a READ statement for any SEQUENTIAL INPUT or UPDATE file. It includes an expression whose integral value specifies a number of records to be skipped over and ignored.

READ FILE (IN) IGNORE (3);

This statement specifies that the next three records in the file are to be skipped.

If a READ statement includes none of the options INTO, SET, and IGNORE, IGNORE(l) is assumed.

The KEY Option

The KEY option applies only to KEYED files associated with data sets of INDEXED or REGIONAL organization.. (The types of data set organization applicable to

record-oriented transmission are discussed-under "Data Set Organization,n below.) The option consists of the keyword KEY followed by a parenthesized expression, which may be a character-string constant" a variable, or any other element expression; i f necessary., the expression is evaluated and converted to a character string. The rules governing the length of the character string and what i t represents are discussed below under

"INDEXED Organizationn and "REGIONAL Organization."

The KEY option identifies a particular record. I t can' be used in a READ statement for an INPUT or UPDATE file, or in a

REWRITE or DELETE statement for a DIRECT UPDATE file.. (The KEY option can be used in a READ statement for a SEQUENTIAL file only if the associated data set has INDEXED organizatien. )

READ FILE (STOCK) INTO (ITEM) KEY (STKEY);

This statement specifies that the record identified by the character-string value of the variable STKEY is to be assigned to the variable ITEM.

The· . KEYFROM . and KEYTO Opti ons

The KEYFROM and KEYTO options apply only to KEYED files associated with data sets of INDEXED or REGIONAL organization, or to TRANSIENT files. Each option consists of the keyword KEYFROM or KEYTO followed by a parenthesized expression.. For KEYFROM, the expression may be a character-string

constant, a variable, or any other element expression; if necessary, the expression is evaluated and converted to a character string.. For KEYTO, the expression must be a character-string variable. The rules governing the lengths of the character strings and what they represent are discussed below, under "INDEXED

Organization" and "REGIONAL Organizationn (except for TRANSIENT files. which are discussed under "Teleprocessing. n )

The KEYFROM option specifies the location within the data set where the record is to be written, or (for TRANSIENT files) the terminal or process queue to which the message or record is to be transmitted. I t can be used in a WRITE statement for a RECORD OUTPUT or DIRECT UPDATE file, or in a LOCATE statement.

WRITE FILE (LOANS) FROM (LOANREC) KEYFROM (LOANNO);

This statement specifies that the value of LOANREC is to be written as the next record in the file LOANS, and that the value of LOANNO is to be used as the key.

The KEYTO option specifies the name of the variable to which the key (or terminal identifier, i f the file is TRANSIENT) of the record being read is to be assigned.

It can be used in a READ statement for a SEQUENTIAL INPUT, SEQUENTIAL UPDATE, or TRANSIENT INPUT file,.

READ FILE (DETAIL) INTO (INVTRY) KEYTO (KEYFLD);

This statement specifies that the next

Dans le document PL/I System/360 (Page 121-124)