Stat (15)
The Stat operation (B_STAT) retrieves the defined characteristics of a file and statistics about the file’s contents, such as the number of records in the file, the number of unique key values stored for each index in the file, and the number of unused pages in the file.
Parameters
 
Prerequisites
The file must be open.
Procedure
1
2
3
4
5
6
Details
The transactional interface returns information about all keys in the file, including those added since file creation. The key information includes any applicable ACS definitions. You must account for this extra information in the Data Buffer. Specifically, do not use the same Data Buffer here that you used for the Create (0) operation.
Because the transactional interface allows up to 119 keys and multiple ACSs in a file, the longest possible Data Buffer is 33,455 bytes (that is, 16 + (11 * 16) + (119 * 265)). However, you probably do not need such a large data buffer. In fact, you may prefer to specify a smaller Data Buffer if you want only certain information. For example, you could set the Data Buffer Length to 1920 bytes (that is, 16 + (16 * 119)). In effect, such a setting returns all key information but not necessarily all the ACSs. If your application does not need information about the ACSs, you might prefer this method.
If you specify a value of 0 in the Key Number parameter, the transactional interface returns Stat information as shown in the following table.
If you specify a value of -1 in the Key Number parameter, the transactional interface returns Stat information as shown in the following table.
File Specifications
The File Specification fields in the returned Data Buffer are the same as those described for Create (14), with the following exceptions:
 
Stat does not indicate whether system data was included by default or explicitly.
Key Specifications
The Key Specification fields in the returned Data Buffer are the same as those described in , except that a 4-byte Number of Unique Key Values follows the Key Flags field and indicates the number of records that have a unique, non-duplicated value for the specified key.
ACSs
The ACS definitions in the returned Data Buffer are the same as those described for Create (14).
Result
If the Stat operation is successful, the transactional interface returns the file and key characteristics to the Data Buffer and the length of the Data Buffer in the Data Buffer Length. If the file is an extended file, the transactional interface returns the filename of the first extension file in the Key Buffer. If the filename of the first extension file is longer than 63 bytes, the transactional interface truncates the filename. If the file is not an extended file, the transactional interface initializes the first byte of the Key Buffer to 0. (You can use the Stat Extended operation to retrieve statistics regarding extended files.)
If the Stat operation is unsuccessful, the transactional interface returns one of the following status codes:
Positioning
The Stat operation has no effect on positioning.