Previous Topic: RELEASE

Next Topic: TRACE

SCAN

The purpose of the SCAN command is to sequentially retrieve records in a table for the purpose of unloading, updating, or deleting those records.

SCAN (TABLE) table-name [HOLD KEY NAME IS key-occurrence-name FROM key-value FOR UNIQUE field-name COUNT xxxx ENTRIES xxx AT-END GO TO {paragraph-name | FINISH} WHEN conditional-clause USE table-name].    

After each successful execution of this command, control is passed to the next CA-Datamacs/II command, which, probably, would be a WRITE, UPDATE, or DELETE statement.

HOLD

HOLD is used to establish exclusive control when a subsequent UPDATE or DELETE command is issued against the record.

KEY NAME IS

This entry identifies the Datadictionary 1-to-32 character key occurrence name to be used. If this keyword is not entered, the key name from the COPY TABLE statement is used, or if no KEY NAME is specified, it will default to the first master key name related to this table as defined in Datadictionary.

FROM

The sequential retrieval will begin with this or the next higher key value. If this entry is not entered, retrieval starts from the beginning of the table and continues until the last record in the table is reached.

UNIQUE The UNIQUE

option will only make the records available which have not been encountered before for the field name(s) specified. Up to 5 fields may be specified, separated by a comma. If more than one record of the same type is needed, enter the number in COUNT. If COUNT is not specified, one is assumed. The expected number of unique ENTRIES should be entered. If not, 100 will be assumed. This entry determines how much computer memory CA-Datamacs/II will allocate to the UNIQUE save area. Careful selection of the unique field will prevent outputting more records than desired. The WHEN statement will be applied before the UNIQUE option. Specifying UNIQUE is optional. Choosing the UNIQUE option probably will degrade performance due to the massive number of comparisons which can occur.

When the UNIQUE option is used and the COUNT threshold is reached, the record is bypassed. If not, the next CA-Datamacs/II statement is given control. It is the user's responsibility to code a WRITE statement to output the record.

AT-END The AT-END

option will receive control after the last record is encountered.

WHEN

Specific records may be selected using the WHEN option. It can only be used on SCAN TABLE. The WHEN must be placed after all other keywords. If the WHEN test fails, CA-Datamacs/II will scan for the next record until AT-END.