Reads the record indicated by a relative record number (random read).
long cobfa_rdrec ( long fd, /* file descriptor */ long readflgs, /* read attribute */ char *recarea, /* record area */ unsigned long recnum /* relative record number */ );
Description
In the file indicated by the file descriptor <fd>, the record specified by the relative record number <recnum> is read and stored in the record area <recarea>.
The read attribute <readflgs> includes the following two categories, which are associated by an OR. If omitted, default values are assigned (default: *).
Read mode (COBOL syntax)
* | FA_EQUAL | Reads the record with the specified relative record number. |
Record lock flag (COBOL syntax)
FA_LOCK | Reads with lock. (READ WITH LOCK) | |
FA_NOLOCK | Reads with no lock. (READ WITH NO LOCK) |
The record lock flag default is affected by the lock mode specified when the file is opened. If the lock mode is automatic lock (FA_LOCK), the default is READ WITH LOCK (FA_LOCK). Otherwise, the default is READ WITH NO LOCK (FA_NOLOCK).
Execution Conditions
File Organization | Sequential file | - |
Record sequential file | - | |
Relative file | Executable | |
Indexed file | - | |
Open Mode | INPUT mode | Executable |
OUTPUT mode | - | |
I-O mode | Executable | |
EXTEND mode | - | |
Access Mode | Sequential | - |
Random | Executable | |
Dynamic | Executable |
Return Values
0: Successful | Function executed successfully |
-1: Failed | Function failed. To get extended error information, call the cobfa_errno or cobfa_stat functions |
Generated Status
Return value of cobfa_errno () | Return value of cobfa_stat () | ||
---|---|---|---|
Successful | FA_ENOERR | 0 | Function executed successfully |
Failure (not all) (*) | FA_ENOTOPEN | 47 | The specified file is opened in a mode other than INPUT mode and I-O mode. Alternatively, an invalid file descriptor is specified |
FA_EBADACC | 90 | The file is opened with the file organization or access mode that does not allow this function to be executed | |
FA_EBADFLAG | 90 | A read mode not allowing execution of this function is specified. Alternatively, another flag specification is incorrect | |
FA_ENOREC | 23 | The record indicated by the relative record number does not exist | |
FA_ELOCKED | 99 | The record specified by the relative record number has been locked |
* : Typical status values are described above. For other values, see "Chapter 5 Error Number and I-O Status".