PositionSet
Establish current ISAM record as current position in set.
Short Name
MIDSET()
Type
ISAM function
Declaration
COUNT PositionSet(FILNO keyno, pVOID recptr, COUNT siglen)
Description
In V12 the file number typedef was formally changed from COUNT, a two-byte value to FILNO, a four-byte value. Refer to this link for compatibility details. Four Byte File Numbering
PositionSet extracts the key value for index keyno from the current ISAM record, and defines a set based on the first siglen bytes of this key value. This permits an application to “jump” into the middle of a set using the current ISAM record to define the set. A successful PositionSet() defines a current key value set, and subsequent calls to NextInSet() and PreviousInSet() will read the other records in the set (i.e., those records whose keys also match the first siglen bytes of keyno). If an error occurs or no key value matches the target, no key value set is defined.
Notice that you do not directly identify the data file number involved. The ISAM parameter file described in ISAM Functions (ISAM Database Technology, /doc/ctreeplus/30841.htm) of the c-tree Programmer’s Reference Guide contains the correspondence between the index file number and the associated data file.
Return
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
NO_ERROR |
Successful retrieval of current ISAM record. |
33 |
DNUL_ERR |
recptr is NULL. No data file read performed. |
42 |
DLOK_ERR |
Could not get lock on data record. No data file read performed. |
100 |
ICUR_ERR |
No current ISAM record. |
101 |
INOT_ERR |
No active entries. |
See c-tree Error Codes for a complete listing of valid c-tree error values.
Example
FILNO keyfil;
TEXT target[24],recbuf[320];
printf("\nEnter set value:");
scanf("%23s",target);
LockISAM(ctENABLE);
FirstInSet(keyfil,target,recbuf,strlen(target));
while (isam_err == NO_ERROR) {
process_data();
LockISAM(ctRESET);
while (NextInSet(keyfil,recbuf) == DLOK_ERR) {
LockISAM(ctSUSPEND);
PositionSet(keyfil,recbuf,strlen(target));
LockISAM(ctRESTORE);
}
}
Limitations
No check is made to determine if recptr points to a region sufficiently large to accept a data record. If the area is too small, either code or data will be clobbered.
See also
NextInSet(), PreviousInSet(), LastInSet(), FirstInSet(), ChangeSet(), TransformKey()