# read and update descriptor

**URL:** <https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Adabas-on-Mainframes, Adabas-Basics-on-Mainframes\
**Created:** [July 21, 2011, 3:50pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775 "2011-07-21T15:50:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![begona\_beldarrain](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@begona\_beldarrain](https://techcommunity.softwareag.com/u/begona_beldarrain)\
**Post date:** [July 21, 2011, 3:50pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775/1 "2011-07-21T15:50:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [July 21, 2011, 4:11pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775/2 "2011-07-21T16:11:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![begona\_beldarrain](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@begona\_beldarrain](https://techcommunity.softwareag.com/u/begona_beldarrain)\
**Post date:** [July 21, 2011, 4:34pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775/3 "2011-07-21T16:34:52Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [July 21, 2011, 11:06pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775/4 "2011-07-21T23:06:34Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:00pm UTC](https://techcommunity.softwareag.com/t/read-and-update-descriptor/97775/5 "2021-04-02T15:00:37Z")

</div>


