# how to count record in natural on adabas file

**URL:** <https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Adabas-on-Windows-UNIX, Adabas-Code-Samples\
**Created:** [February 2, 2016, 1:42pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609 "2016-02-02T13:42:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister\_Ramon](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@Mister\_Ramon](https://techcommunity.softwareag.com/u/Mister_Ramon)\
**Post date:** [February 2, 2016, 1:42pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/1 "2016-02-02T13:42:43Z")

</div>

is it possible?  
in sql I use select count(1) from sql\_table, but in natural , how can I do?

I’ ve a file adabas with 400.000 records.  
if i do

```auto

read adabas_file
    add 1 to #numrec
end-read
write #numrec

or 

rd. read adabas_file
end-read
write *counter(rd.)
```

i’ve error for too many read in file adabas:  
NAT1009 Program interrupted after too many database calls.

I’m studing adabas and natural  
thank you

---

<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:** [February 2, 2016, 2:36pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/2 "2016-02-02T14:36:36Z")

</div>

```auto
FIND NUMBER adabas_file WITH descriptor > somevalue
```

for a descriptor where you know an value exists for every record with “somevalue” that doesn’t skip any of them.

---

<div class="post-metadata">

**Author:** ![Mister\_Ramon](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@Mister\_Ramon](https://techcommunity.softwareag.com/u/Mister_Ramon)\
**Post date:** [February 2, 2016, 2:54pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/3 "2016-02-02T14:54:02Z")

</div>

thank you 🙂  
it’s work

```auto

FIND NUMBER adabas_file WITH idkey > 0
WRITE *NUMBER 
```

with idkey (i4) like counter and ever \> 0  
thank you

---

<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:** [February 2, 2016, 3:24pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/4 "2016-02-02T15:24:20Z")

</div>

Hi Wolfgang;

A number of years ago I did a timing comparison between code like:

FIND NUMBER myview WITH DBFIELD \> ’ ’

versus

HISTOGRAM myview DBFIELD  
ADD \*NUMBER TO #SUM  
END-HISTOGRAM

The HISTOGRAM won. If I recall correctly, this was because the FIND NUMBER created an ISN list, even if RETAIN AS was not included in the statement. This was especially true when the HISTOGRAM was multifetched.

Has this changed?

steve

---

<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:** [February 3, 2016, 12:59am UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/5 "2016-02-03T00:59:38Z")

</div>

I believe that Wolfgang suggested FIND NUMBER to avoid the NAT1009, not for the sake of performance. FIND NUMBER won’t work if all the file’s descriptors are null suppressed.

I would have used a multi-fetched READ PHYSICAL with no fields in the view, but it wouldn’t work if MADIO is set very low. For Mister Ramon to read his 400,000 record file with Natural for Windows, MADIO would need to be set at 50,000 or better. On the mainframe you could multi-fetch 1000, so MADIO could be as low as 400.

---

<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:35pm UTC](https://techcommunity.softwareag.com/t/how-to-count-record-in-natural-on-adabas-file/186609/6 "2021-04-02T15:35:17Z")

</div>


