Previous Topic: Concurrent Access to Multiple UDBs

Next Topic: Release File Processing Resources

Data Set Positioning and Generic Retrieval

NCL supports both sequential and generic retrieval from keyed data sets. Such functions imply that a current position within the file is maintained. Thus, the NCL procedure can simply request the next record and it is supplied.

Example: Data Set Positioning and Generic Retrieval

&FILE OPEN ID=FILE1 FORMAT=DELIMITED   -* Open file 1
&FILE OPEN ID=FILE2 FORMAT=DELIMITED   -* Open file 2
.LOOP
   &FILE GET ID=FILE1 OPT=SEQ VARS=A* RANGE=(1,6)
                                       -* Read record
   &IF &FILERC NE 0 &THEN &GOTO .ENDPROC
                                       -* End if not 0
   &X = &FILEKEY                       -* Copy key of
                                       -* record that was
                                       -* read into
                                       -* variable
   &FILE PUT ID=FILE2 KEYVAR=X VARS=(A1,A2,A3,A4,A5,A6)
                                       -* Write record
   &GOTO .LOOP                         -* Loop to read
                                       -* next record on
                                       -* file 1

Note: This example does not fully cater for such things as error conditions.

It is not necessary for the NCL procedure to increment keys.

Under certain circumstances, such as with generic retrieval, it might be necessary to alter the retrieval sequence and commence retrieval using a different key.

NCL must be informed that such a change is required and that the current retrieval sequence is to be stopped. This is done using the &FILE GET ID=fileid OPT=END statement. This indicates to NCL that generic retrieval is to be terminated in anticipation of some other processing.

If an end-of-file condition is signaled, no &FILE GET ID=fileid OPT=END is required. The use of a non-generic function, such as the specific retrieval of a record, also cancels a previous generic function.