STORE Multiple Field Counter

Is it possible to use the STORE command to insert a record into the database containing a multiple field and setting the field counter at the same time?

  • This forum is for posting code examples to share with other subscribers. This post belongs in a Natural Basics forum.

Adabas computes and stores the occurrence count; it cannot be set programmatically. We can only retrieve it.

mu-field (1) := ... 
mu-field (2) := ... 
...
S. 
STORE view            /* Adabas computes count
GET view *ISN (S.)    /* retrieve count
DISPLAY C*mu-field    /* display count

An add-on to Ralph’s comment. The key phrase in the comment is

“it cannot be set programmatically”.

HOWEVER, it can be changed in the program. Here is a program than changes C*LANG

DEFINE DATA LOCAL
1 MYVIEW VIEW OF EMPLOYEES
2 NAME
2 CLANG
2 LANG (1:5)
END-DEFINE
*
READ (1) MYVIEW
DISPLAY ISN CLANG LANG (1:5)
MOVE ‘aaa’ TO LANG (2)
MOVE ‘bbb’ TO LANG (3)
MOVE ‘ccc’ TO LANG (4)
UPDATE
LOOP
*
READ (1) MYVIEW
DISPLAY ISN CLANG LANG (1:5)
LOOP
*
READ (1) MYVIEW
MOVE 3 TO C
LANG
DISPLAY ISN CLANG LANG (1:5)
UPDATE
LOOP
*
READ (1) MYVIEW
DISPLAY ISN CLANG LANG (1:5)
LOOP
BACKOUT TRANSACTION
END

In the first READ loop, I read a record and DISPLAY the count and the languages (actually, just one). I also put data in the 2-4 occurrences.

In the second loop I read the same record and DISPLAY the same variables. Note below that c* is now 4 and the data is as I entered it.

In the third loop I changed c* to 3. Since the DISPLAY follows the MOVE, you see the value 3. I then UPDATE’d the record with the altered value of c*.

HOWEVER, when in the fourth loop I read the record again, c* is actually 4, not 3.

PAGE #   1                    DATE:    Jun 23, 2009
PROGRAM: MU100                LIBRARY: INSIDE

ISN      LANG   LANG
        SPOKEN SPOKEN

     11    1   FRE




     11    4   FRE
               aaa
               bbb
               ccc

     11    3   FRE
               aaa
               bbb
               ccc

     11    4   FRE
               aaa
               bbb
               ccc

This is now a pure guess as to why you can change c*. In the original release of Adabas, there was only one way to UPDATE an MU field. You changed the entire field, not just individual occurrences. The capability to change individual occurrences was added later. Natural just implemented the individual occurrence capability, not the original entire field method.

My guess is that the developers were considering implementing both approaches. However, due to the potential for really making a mess of the database if you do not know what you are doing with the “old way”, it was decided to go with just the “new way”. If you were going to implement the old way, you would have the capability to change c*, hence my “guess”.

The summary of all the above:

It is legal to change c*. However, it does not affect the count that Adabas keeps of how many occurrences there are.

steve