flak@slovax.UUCP (Dan Flak) (01/13/88)
Informix doesn't provide a utility to provide you with the number of records in a database file. I know from playing around with octal dumps that the number is stored in bytes x & y in the index file. However, I suspect that these byte positions vary from machine to machine, and depend upon byte ordering. Since Informix no longer supports Version 3.30, it's very unlikely that they will add this feature. The following provides one (not terribly graceful) means for getting the number of records in a database. 1. Invoke dbstatus 2. execute 'print status to "STATUS" 3. quit dbstatus 4. awk -f stat.awk STATUS The stat.awk file looks like: ===== BEGIN {nrecs = 0} $1 ~ /file/ {printf ("For file %s, number of records = ",$2)} $3 ~ /records/ {printf ("%d\n",$4); nrecs += $4} END {printf ("Total number of records = %d\n",nrecs)} ===== I don't have a need to do this frequently, so I can live with the steps outlined above. Ideally, there should be a "dbrecnum" call in the ALL library to handle this situation. Something like: int dbrecnum (filename, numrecs) char *filename; int *numrecs; would be handy. If anyone has done this, or intends to do this, I'd like a copy. -- {hplsla,uw-beaver}!tikal!slovax!flak Dan Flak-R & D Associates,3625 Perkins Lane SW,Tacoma,Wa 98499,206-581-1322