dsetpos - set position in secondary index


#include <cbase/dirio.h>

rno_t dsetpos (recno, index, fcb)

rno_t recno;

int index;

DFILE *fcb;


An RMSfile may have several secondary keys associated with it in addition to the primary key. These are used to find records by the key value. The dsetpos function restores the position in an RMSfile after you find records with another key.

RMS keeps track of the current position in the RMSfile so that records can be read in key order. The dsetpos function sets the current position in the index where index reading continues, so reading in key order can proceed from a known point. This allows you to switch indexes or combine calls to index routines and primary keyed reads.

The recno parameter selects the record where the RMSfile should be positioned. The RMSfile is positioned so that the next record read is the record following the record specified. If recno is zero, then the current record number is used.

Index is an integer naming the index to be used. The secondary indexes are numbered starting at 1. An index of zero specifies the primary key of an RMSfile.

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

Dsetpos returns the new current record number.


dlopen(C-3), dopen(C-3), dfindfi(C-3), dfindi(C-3), dfindni(C-3), dfindli(C-3), dfindpi(C-3), dfindm(C-3), dfindnm(C-3), dfindlm(C-3), dfindpm(C-3), dnumidx(C-3)

Chapter 4,

RMS Programming Guide


Dsetpos return a value of BAD (-1) if an invalid secondary index number or record number is selected.