HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 1 INTRODUCING KSAM/3000

OVERVIEW

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

The Keyed Sequential Access Method (KSAM) is a method of organizing records in a file according to the content of key fields within each record. As implemented for the HP 3000 computer system, KSAM/3000 is similar to and competitive with other indexed sequential access methods.

Every record in a KSAM file contains a primary key field whose contents determine the primary logical sequence of records in the file. Other key fields can also be defined so that the file can be sequenced in alternate orders. The order in which records are physically written to the file, the chronological order, can be the same as the primary key sequence or it can be unrelated to any logical sequence.

KSAM/3000 files can be accessed by programs written in any of these languages:

  • RPG/3000

  • COBOL II/3000

  • COBOL/3000

  • SPL/3000

  • FORTRAN/3000

  • BASIC/3000

KSAM/3000 files can be copied, listed, and otherwise manipulated with the utility programs:

  • FCOPY/3000

  • KSAMUTIL

FILE STRUCTURE

A KSAM/3000 file is organized into two distinct MPE files, a data file and a key file. The key file contains only key entries, the data file only data. Each record in the data file contains at least one item that is designated as a key. The value of each key is duplicated in the key file where all keys are ordered in ascending sequence. This organization allows records in the data file to be stored in any order since the key file maintains the logical order of records according to key value.

Although it is not necessary to understand KSAM file structure in order to use a KSAM file, you may want to refer to appendix B for a detailed discussion of the relation between data and key files and the structure of the key file.

NOTE: Each open KSAM file uses three file numbers; two for the data and keys and one for internal maintenance. The maximum number of KSAM files that can be opened for a process depends upon the stack of that process.

FILE ACCESS

Although separate in fact, the two files that comprise a KSAM file are treated as one file by the procedures that reference the file. The data file is the only file directly referenced by a user; the key file is updated by the system to reflect any changes to the data file and is not directly accessed by the user. Thus, from the user's point of view, accessing a KSAM file is very similar to accessing any other MPE file.

KSAM/3000 provides the following ways to store and retrieve data:

  • You can write records in logical sequence determined by primary key value or you can write records without regard to key sequence.

  • You can read records in logical sequence determined by either the primary or an alternate key value.

  • You can read a record selected at random by the value of its primary or alternate keys.

  • You can read records in the order they were written, that is, in chronological sequence, unless the program is written in COBOL or BASIC.

  • You can read a record selected by the value of its chronological record number, unless the program is written in COBOL or BASIC.

  • You can update all the contents of an existing record including the contents of the primary key field.

  • You can position to a record in the file according to its key value, its chronological record number, or its record number in key sequence.

NOTE: KSAM files are sequenced in ascending order only, not in descending order. Character keys are ordered by the ASCII collating sequence where numbers precede letters, not in the EBCDIC sequence where letters precede numbers. Numeric keys are ordered in algebraic order.
Feedback to webmaster