Operating System - OpenVMS
1827887 Members
1634 Online
109969 Solutions
New Discussion

Re: number or records in RMS file

 
rison so_1
Advisor

number or records in RMS file

How can I find out how many records in a RMS file ?
6 REPLIES 6
Phil.Howell
Honored Contributor

Re: number or records in RMS file

$ search /log /noout /match=or file.dat ""
Phil
Karl Rohwedder
Honored Contributor

Re: number or records in RMS file

Pls. note the /STATISTICS qualifier for SEARCH, which since V8.3 let SEARCH create some DCL symbols for such infos:

sear/stat/noout login.com hallo

Files searched: 1 Buffered I/O count: 6
Records searched: 194 Direct I/O count: 2
Characters searched: 6215 Page faults: 25
Records matched: 0 Elapsed CPU time: 0 00:00:00.01
Lines printed: 0 Elapsed time: 0 00:00:00.03


%SEARCH-I-NOMATCHES, no strings matched
SAP01_Rohwedder. sh sym search*
SEARCH$CHARACTERS_SEARCHED = "6215"
SEARCH$FILES_SEARCHED = "1"
SEARCH$LINES_PRINTED = "0"
SEARCH$RECORDS_MATCHED = "0"
SEARCH$RECORDS_SEARCHED = "194"

regards Kalle
Richard Whalen
Honored Contributor

Re: number or records in RMS file

You didn't say whether you wanted to find out the number of records from DCL (from which the above responses will give you an exact answer), or as part of your program. The only way for a program to get the exact number for a file with variable length records is to read all the records and keep a count.

If you want you program to compute the number of records, then a file with fixed length records can be easily be computed as size of the file (in bytes) divided by the record length. For a variable length record file, you can use the maximum record length and you will get a lower bound on the number of records in the file.
Ian Miller.
Honored Contributor

Re: number or records in RMS file

Note that the Max Record Size or Longest Record Length fields are not always correct.
____________________
Purely Personal Opinion
Hein van den Heuvel
Honored Contributor

Re: number or records in RMS file


>> How can I find out how many records in a RMS file ?

By counting them!
Seriously.

The only time you can calculate it from the file size is for fixed length records in a sequential file.
(In DCL check out lexical F$FILE items EOF, FFB and MRS)

See also: http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=779260

The 'right way' to count depends on your needs, feeds and speeds.
Input:
- Sequential? Indexed?
- Variable length? Fixed length?
- a few MB or several GB of data?
- Currently open file in shared mode?
Output:
- Any performance requirements?
- Any accuracy requirements
- Into program variable or on screen or DCL symbol/logical?

$SEARCH/STAT and $CONVERT/STAT of often reasonable generic tools.

I also use:

$perl -ne "END {print $.}"

GNV's: wc

I wrote a specific program (attached) for this problem which handles general files, but specifically OPEN, SHARED, indexed files with global buffers where you do not record lockign activity, and you do not want the count tool to flush out the useful global buffers. It outputs to screen, and into a symbol.

Finally, for large indexed files ( > 10 GB ) you probably want to use a serious tool. Check out the 'DIX' freeware, or the SELECT commercial tool by EGH (contact me for details)

Regards,
Hein van den Heuvel
HdvH Performance Consulting



rison so_1
Advisor

Re: number or records in RMS file

Thanks