HP 3000 Manuals

Using KSAM [ Getting Started With TRANSACT V ] MPE/iX 5.0 Documentation


Getting Started With TRANSACT V

Using KSAM 

Adding Records 

Adding a record to a KSAM file uses the same verbs and syntax as adding a
record to an IMAGE dataset.  Compare this program with Ex9 in Figure 2-3.
____________________________________________
|                                          |
|     1     system ex32,ksam=kcust(update);|
|     2     set(delimiter) "/";            |
|     3     level;                         |
|     4       prompt cust-no;              |
|     5       prompt name;                 |
|     6       put kcust;                   |
|     7     end;                           |
____________________________________________

          Figure 4-1.  Program to add data to a KSAM file 

1       The KSAM= option names the KSAM file to be accessed.  The default
        access is READ only.  The most inclusive capability is UPDATE.
___________________________________________________________________
|                                                                 |
|     CUST-NO> 301                                                |
|     NAME> Wheeler Dealer                                        |
|     CUST-NO> 301                                                |
|     NAME> My Place                                              |
|     *ERROR: DUPLICATE KEY VALUE  (FSERR 171)  (KSAM 171,4,KCUST)|
|     CUST-NO> ]                                                  |
___________________________________________________________________

          Figure 4-2.  Adding data to a KSAM file 
_____________________________________________
|                                           |
|      1     system ex33,ksam=kcust(update);|
|      2     set(delimiter) "/";            |
|      3     list(auto) kcust;              |
|      5     data cust-no;                  |
|      6     set(key) list (cust-no);       |
|      7     get kcust;                     |
|      8     display;                       |
|      9     data name;                     |
|     10     set(update) list(name);        |
|     11     replace kcust;                 |
|     12     end;                           |
_____________________________________________

          Figure 4-3.  Program to update data in a KSAM file 

10      In the KSAM file, both data items are key fields.  Therefore, to
        change a field we need to add a new record and delete the old.
        We can code the steps ourselves, or we can take advantage of the
        REPLACE capability in Transact.  SET(UPDATE) prepares to let
        Transact do the delete and add for us.  In this statement, we
        tell Transact each field that we are going to update.

11      REPLACE does the add and delete, thereby changing the value for
        name to the new value we input.
_____________________________________
|                                   |
|     CUST-NO> 301                  |
|                                   |
|     CUST-NO: NAME:                |
|      301      Wheeler Dealer      |
|                                   |
|     NAME> My Place                |
|     CUST-NO> 301                  |
|                                   |
|     CUST-NO: NAME:                |
|      301      My Place            |
|                                   |
|     NAME> ]                       |
_____________________________________

          Figure 4-4.  Updating data in a KSAM file 


MPE/iX 5.0 Documentation