dfindi - find first record using secondary index


#include <cbase/dirio.h>

rno_t dfindi (buffer, fcb)

char *buffer;

DFILE *fcb;


Dfindi finds the first record that has field values greater than or equal to the beginning field values placed in the data buffer. If dnumidx(C-3) has been called prior to this function, only the first n fields of the current index are compared; otherwise, all fields of the current index are compared. Any field values stored in the data buffer that are not part of the current index are ignored.

An RMSfile may have several secondary indexes associated with it. These are used to retrieve records by other than the primary key value. Before calling dfindi, call dseti(C-3) to select the desired secondary index. The selected secondary index has between one and eight fields associated with it. The beginning values for the secondary index fields desired must be stored in buffer before calling dfindi.

Dfindi returns into the buffer the first record that contains secondary field values greater than or equal to the field values passed in buffer. Dfindi also saves the current position in the secondary index, and additional records may be fetched in secondary key order with the dfindni(C-3) function.

Fcb is the file block pointer returned by dlopen(C-3) or dopen(C-3).

The returned record number may be saved and used on a subsequent call to dread(C-3).


dlopen(C-3), dopen(C-3), dseti(C-3), dnumidx(C-3),

dfindni(C-3), dread(C-3)

Chapter 4,

RMS Programming Guide


Dfindi returns a value of BAD (-1) if an I/O error occurred, or if there is no record that contains field values equal to or greater than the beginning values passed in buffer. If no record is found, the contents of buffer are undefined.