read and update descriptor

I would know the better way for UPDATE/DELETE a descriptor in a read loop

I wonder that because I’m maintaning a legacy system, and there is always the structure

R1. READ ACCOUNT WITH ACCOUNT-ID > 123000
G1. GET ACCOUNT ISN ISN (R1)
ACCOUNT-ID := 123456
UPDATE (G1.) /
or delete
END TRANSACTION
END-READ.

ACCOUNT-ID is NOT an unique Descriptor.

Thanks.

Your program excerpt makes no sense whatsoever. I am sure there must be other code you have not shown us.

The idea of GET’ing a record within a READ (or FIND) loop is associated with conditional updating.

For example:

READ
::::
IF some condition is true
GET *ISN
UPDATE
END-IF
:::
END-READ

If you have an UPDATE that refers to a READ, all the records READ will be held. Suppose you are reading a million record file and only forty records will pass the IF test. Now, the READ does not hold the record. Only records that pass the IF, and you GET, will be held.

A side note. If you are changing the value for a logical read (to a higher value), you will likely see the same record again (unless you have ESCAPE’d the loop).

Please post a more complete picture of the code. To repeat, as posted, the code makes no sense.

steve

Thank you, Steve , for your answer.

I’ve simplified the code in the post before.

The reel code is like this :
READ file1 WITH descriptor1 = wdescriptor1
IF descriptor1 NE wdescriptor1
ESCAPE BOTTOM
END-IF
ADD 1 TO CON-VALOR
ISN-AUX := ISN
SU1. GET file1 ISN-AUX
file1.descriptor2 := valor2 /
other descriptor
UPDATE (SU1.)
ADD 1 TO GRABADOS
IF GRABADOS > 100
RESET GRABADOS
END TRANSACTION
END-IF
END-READ

There is not condition for update. I was looking for a valuable argument
to avoid that GET. I didn’t remember exactly when the hold is done .

Sad to say, but I have seen this structure in many production programs - all the result of a rookie programmer misunderstanding Adabas’ hold logic and transaction timers. Several factors, such as file size and key distribution, must be considered when determining the structure of an update program. The goal is to be as efficient as possible for those factors.

What this programmer has found, is that his structure works for all situations. But this is also the most costly solution; if all records are updated, then there is no need for the GET.

R1. 
READ file1 WITH descriptor1 
           FROM wdescriptor1
             TO wdescriptor1
  ADD 1 TO CON-VALOR
  file1.descriptor2 := valor2 /* other descriptor
  UPDATE (R1.)
  ADD 1 TO GRABADOS
  IF GRABADOS > 100
    RESET GRABADOS
    END TRANSACTION
  END-IF
END-READ
END TRANSACTION 

To test this program, replace the UPDATE statement with a DISPLAY.