how to count record in natural on adabas file

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


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

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.

thank you :slight_smile:
it’s work


FIND NUMBER adabas_file WITH idkey > 0
WRITE *NUMBER 

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

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

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.