HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 2 USING KSAM UTILITIES

KEYSEQ

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

Verifies sequence of key values in KSAM file.

 

   >{ KEYSEQ 

      KS     } [filereference] [;SEQ=keysequence] [;OFFLINE] [;NOLIST] 

This command compares all the key values in a particular key (primary or alternate) to determine whether they are in ascending sequence. If any values are out of sequence, a list of numbers identifying such values is displayed, unless NOLIST is specified. In any case, the number of outquence values is returned. Note that if key values are out of sequence, the key file is damaged and the KSAM file must be reloaded.

The abbreviation KS may be used instead of the keyword KEYSEQ.

PARAMETERS

filereference

Actual file designator identifying the KSAM file whose key values are to be verified. Either the data file name or the key file name can be used to identify a KSAM file. Also, a back reference to a file named in an MPE :FILE command may be used.

(Optional parameter if no parameters are specified.)

Default: If omitted, the last file referenced is assumed.

SEQ= keysequence

Identifies particular key whose key values are to be checked. Keys are numbered from 1. The first key (SEQ=1) is always the primary key; subsequent keys are alternate keys numbered in the order they appear in the record, such that the first alternate key in the record is SEQ=2, the second alternate key is SEQ=3, and so forth.

(Optional parameter.)

Default: If omitted, the primary key is assumed.

OFFLINE

Directs list of out-of-sequence keys to the line printer. An MPE :FILE command may be used to indicate a different output device than the line printer, or a particular line printer.

(Optional parameter.)

Default: If omitted, the list of out-of-sequence keys is displayed at user's terminal.

NOLIST

Suppresses display of the particular key numbers whose values are out of sequence. A count of the out-of-sequence values is displayed even if NOLIST is specified.

(Optional parameter.)

Default: If omitted, list of key numbers for out-of-sequence key ualues is displayed.

VERIFY KEY SEQUENCE

If you suspect that your key file has out of order key values in any key, you can run KEYSEQ. If any key values are not in ascending sequence, the key numbers associated with those key values are displayed. Note that the number of a key value refers to its position in the key file. For example, if the third, fourth, and fifth key values of a particular key are out of sequence, the numbers 3, 4, and 5 are displayed.

If the list of out-of-sequence key numbers is long, you can terminate it by holding down the CNTL key while typing Y (CNTL/Y). The total number of out-of-sequence key values will be displayed even if you terminate the list with CNTL/Y or suppress it altogether with NOLIST.

Consider the following partiallist of key values in the primary key of the KSAM file MYFILE:

[f0201e]

If you run KSAMUTIL and use the KEYSEQ command, as shown below, you can determine which keys are out of order:

 

   :RUN KSAMUTIL.PUB.SYS 

   >KEYSEQ MYFILE ;SEQ=1<----------- test primary key sequence 

KEYSEQ displays the following:

 

   KEY VALUE # (FOR VALUE OUT OF SEQUENCE) 

   3  <------ key number of keys with out-of-sequence values 

   4  <-------| 

   TOTAL # OF KEY VALUES READ       30 

   # OF KEY VALUES OUT OF KEY SEQUENCE ORDER            2 

   KEY FILE STRUCTURE DAMAGED, KSAM FILE HAS TO BE RELOADED 

Regardless of the number of key values that are out of sequence, you should reload the KSAM file to restore its integrity.

Consider a second example. Suppose MYFILE has two alternate keys, one starting in location 11 (11th character of record) and another starting in location 33. To verify the sequence of key values in the second alternate key, execute KEYSEQ as follows:

 

     >KS MYFILE ;SEQ=3 ;NOLIST <----- suppress list of key numbers 

                     ↑ 

                     |------ second alternate key 



     TOTAL # OF KEY VALUES READ 30 

     #OF KEY VALUES OUT OF KEY SEQUENCE ORDER 0 <--- key values in sequence 

In this case all the key values were in correct sequence. Unless other keys in this file have values that are out of sequence, you need not reload the file.

Note that NOLIST was specified. In general this is good practice. If any key values are not in sequence, the file should be reloaded, so it is seldom important to know which keys are out of sequence.