# Error nat3047 - help

**URL:** <https://techcommunity.softwareag.com/t/error-nat3047-help/289316>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, NaturalONE\
**Created:** [January 2, 2024, 5:21pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316 "2024-01-02T17:21:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Imnacho2000](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/imnacho2000/32/31777_2.png) [@Imnacho2000](https://techcommunity.softwareag.com/u/Imnacho2000)\
**Post date:** [January 2, 2024, 5:21pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/1 "2024-01-02T17:21:02Z")

</div>

Hi i need to update a some objects from “VIEW OF” and when try have this error “ERROR NAT3047”

The code is very simple it’s a

R1. READ view of  
IF condition  
UPDATE ( R1. )  
END-TRANSACTION  
END-IF  
END-READ

this is my totals variables

TOTAL LEIDOS…: 3.160.003  
TOTAL ACEPTADOS…: 46.285  
TOTAL ACTUALIZADOS…: 255

where TOTAL LEIDOS its from the view  
TOTAL ACPETAODOS the objects that passed  
TOTAL ACTUALIZADOS the objects that i need to update.

thanks for reading and any help it’s welcome here!

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [January 2, 2024, 6:04pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/2 "2024-01-02T18:04:57Z")

</div>

NAT3047 indicates you have too many records on hold. You are reading and holding 3m records and updating 255 of those.  
There are different approaches that can be used, but for what you describe, something like this might be better:  
R1. READ view1…/\* view1 has just the fields needed to evaluate “condition”  
IF condition  
G1. GET view2 _ISN(R1.)  
/_ move updated values to “view2”  
UPDATE (G1.)  
END TRANSACTION  
END-IF  
END-READ

This ensures that only records needing to be updated are put on the hold queue at a small cost of re-reading the records to put them on hold. You can use MULTI FETCH on the READ statement to improve performance.

Your original program puts lots of records on the hold queue and only releases them when “condition” is satisfied. If a large portion of the records being read are also being updated, you can use a periodic ET to release - something like:  
R1. READ …  
ADD 1 to #ET-CTR  
IF condition  
UPDATE (R1.)  
/\* optionally, do ET here and reset counter if ET for each update is needed  
END-IF  
IF #ET-CTR \> 100  
RESET #ET-CTR  
END TRANSACTION  
END-IF  
END-READ  
END TRANSACTION  
Avoid using a WHERE clause on the READ statement with this approach.

---

<div class="post-metadata">

**Author:** ![Eugene.Miklovich](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Eugene.Miklovich](https://techcommunity.softwareag.com/u/Eugene.Miklovich)\
**Post date:** [January 2, 2024, 6:08pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/3 "2024-01-02T18:08:23Z")

</div>

When you have an UPDATE inside a READ or FIND loop NATURAL generates a READ and HOLD call to ADABAS in case you want to actually update the record. In your case the update is conditional but the records are still being held. Thus you held too many records and exceeded the limit (hence 3047). I suggest you either add a counter and do an ET every 50 records to release them or:

Inside the IF do a GET to reread the record you are updating and then have the UPDATE refer back to the GET so only the actual records to be updated are held (still should have a counter). Final option if it is a FIND to move the condition into the WITH clause so ADABAS only returns records to be updated.

😊

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

---

<div class="post-metadata">

**Author:** ![Mariano\_Cadaia](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Mariano\_Cadaia](https://techcommunity.softwareag.com/u/Mariano_Cadaia)\
**Post date:** [January 2, 2024, 6:27pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/4 "2024-01-02T18:27:31Z")

</div>

Hola Nacho,

La explicacion de Douglas es correcta.  
El problema es que estas HOLDEANDO muchos registros en comparacion con la cantidad que actualizas. ADABAS bloquea todos los registros que leeas (aunque no entren en el IF) si tenes un UPDATE, y tiene un limite de registros holdeados sin hacer END TRANSACTION

Lo mas performante es hacer un get en una segunda View, la cual contenga solo los campos que queres actualizar. Y llevar un control de transacciones, por ejemplo cada 50 registros actualizados hacer ET.

Saludos  
Mariano

---

<div class="post-metadata">

**Author:** ![Imnacho2000](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/imnacho2000/32/31777_2.png) [@Imnacho2000](https://techcommunity.softwareag.com/u/Imnacho2000)\
**Post date:** [January 2, 2024, 7:11pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/5 "2024-01-02T19:11:37Z")

</div>

Thank you so much!, your answer is the solution, sorry for my ignorance i’m trainee in this haha

greetings from argentina!

---

<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:** [June 30, 2024, 7:11pm UTC](https://techcommunity.softwareag.com/t/error-nat3047-help/289316/6 "2024-06-30T19:11:51Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
