HP 3000 Manuals

Using KSAM and MPE Files [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

Using KSAM and MPE Files 

When using KSAM and MPE files, it is best to define a buffer record whose
child items are the pieces of the record.  Then you can read, write, or
list the record by the buffer name and also refer to the items
individually.

Defining a Buffer Record 

The following example shows how to define a buffer record that contains
all fields.

     SYSTEMS FREC, FILE= WORK(ACCESS(R/W),40,3,100);

       DEFINE(ITEM) BUFFER X(80):
                    ITEM1  X(25) = BUFFER(1):
                    ITEM2  X(30) = BUFFER(26):
                    ITEM3  X(15) = BUFFER(56):
                    ITEM4  X(10) = BUFFER(71);

       LIST BUFFER;

       GET(SERIAL) WORK, LIST=(BUFFER);

       DISPLAY ITEM1:
               ITEM2:
               ITEM3:
               ITEM4;

       DATA(SET) ITEM1:
                 ITEM2:
                 ITEM3:
                 ITEM4;

     END FREC;

The LIST= option must contain either the entire KSAM record buffer or
some beginning portion of the record.  In other words, Transact must know
where the beginning of the buffer is to calculate key offsets, since the
first item in the LIST= option is used to determine where the record
starts.  Transact needs this information to call FFINDBYKEY, which
requires the key position as one of its parameters.

          Table 6-4 Understanding the KSAM Interface 

-------------------------------------------------------------------------------
|                                                                             |
|                              KSAM File Access                               |
|                                                                             |
-------------------------------------------------------------------------------
|                |              |                                             |
| Transact Verb  |   Key Type   |              File Defined As:               |
|                |              |                                             |
-------------------------------------------------------------------------------
|                |              |                      |                      |
|                |              |       MPE File       |      KSAM File       |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
| FIND(SERIAL)   | N/A          | Primary key sequence | Chronological        |
|                |              |                      | sequence             |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
| FIND(CHAIN)    | PRIMARY      | Reads chronological  | Primary key sequence |
|                |              | record zero and then |                      |
|                |              | primary key sequence |                      |
|                |              | until EOF            |                      |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
|                | SECONDARY    | Same as primary      | Secondary key        |
|                |              |                      | sequence             |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
| FIND           | None         | One record primary   | Error                |
|                |              | key sequence         |                      |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
|                | PRIMARY      | Same as no key       | One record of        |
|                |              |                      | primary key value    |
|                |              |                      |                      |
-------------------------------------------------------------------------------
|                |              |                      |                      |
|                | SECONDARY    | Same as no key       | One record of        |
|                |              |                      | secondary key value  |
|                |              |                      |                      |
-------------------------------------------------------------------------------



MPE/iX 5.0 Documentation