Reads a record sequentially (sequential read).
long cobfa_rdnext ( long fd, /* file descriptor */ long readflgs, /* read attribute */ char *recarea /* record area */ );
Description
In the file indicated by the file descriptor <fd>, the record immediately after (or before) the current record 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_NEXT | Reads the next record. (READ NEXT RECORD) |
FA_PREV | Reads the previous record. (READ PREVIOUS RECORD) |
If the file is a line sequential file (FA_LSEQFILE) or record sequential file (FA_SEQFILE), previous record (FA_PREV) cannot be specified for the read mode.
Record lock flag (COBOL syntax)
FA_LOCK | Reads with lock. (READ WITH LOCK) | |
FA_NOLOCK | Reads with no lock. (READ WITH NO LOCK) |
The default of the record lock flag depends on the lock mode specified when the file is opened. If the lock mode is automatic lock (FA_AUTOLOCK), the default is READ WITH LOCK (FA_LOCK). Otherwise, the default is READ WITH NO LOCK (FA_NOLOCK).
Execution Conditions
File Organization | Sequential file | Executable (*) |
Record sequential file | Executable (*) | |
Relative file | Executable (*) | |
Indexed file | Executable (*) | |
Open Mode | INPUT mode | Executable (*) |
OUTPUT mode | - | |
I-O mode | Executable (*) | |
EXTEND mode | - | |
Access Mode | Sequential | Executable (*) |
Random | - | |
Dynamic | Executable (*) |
* : File positioning must not be optional.
Return Values
0: Successful | Function executed successfully. A code indicating the status may be set in the I-O status. |
-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 |
FA_ENOERR | 2 | The value of the reference key in the record that is read is equivalent to the value of the reference key in the next record | |
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 access mode that does not allow this function to be executed | |
FA_EENDFILE | 10 | A file ending condition occurred. | |
FA_EBADFLAG | 90 | A read mode that does not allow execution of this function is specified. Alternatively, another flag specification is incorrect | |
FA_ENOCURR | 46 | Positioning to the record was undefined | |
FA_ELOCKED | 99 | The record to be positioned by sequential read has been locked |
* : Typical status values are described above. For other values, see "Chapter 5 Error Number and I-O Status".