CreateIndexMember
Create an additional index file member.
Short Name
CREMEM()
Type
Low-Level index file function
Declaration
COUNT CreateIndexMember(FILNO keyno, COUNT keylen,
COUNT keytyp, COUNT keydup, COUNT membno)
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
CreateIndexMember() attempts to add an additional index to index file number keyno, just created by CreateIndexFile(). This additional index file member has a key length of keylen bytes.
keytyp determines whether keys are fixed length or use some form of compression. See Alternative Key Types for more information.
keydup of 0 indicates no duplicates allowed, and a value of 1 indicates duplicate keys are supported.
membno must be in the range from 1 to the number of members set by the previous call to CreateIndexFile() (see the nomemb parameter of CreateIndexFile()). Subsequent calls to other Low-Level index file functions use keyno + membno to reference this file. For example, if keyno is three (3) and membno is two (2), then this additional index file member is referenced as file number five (5).
Return
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
NO_ERROR |
Index file member successfully added. |
20 |
KMIN_ERR |
Key length too large for node size (determined by node sectors in call to InitCTree()). There must be room for at least four key values per node. |
23 |
KMEM_ERR |
membno < 1 or membno greater than number of additional members established for the index keyno. |
45 |
KLEN_ERR |
Key length exceeds MAXLEN parameter in ctoptn.h. |
46 |
FUSE_ERR |
File number keyno + nomemb is already in use. |
48 |
FMOD_ERR |
keyno is not assigned to an index file. |
See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.
Example
FILNO keyno = 0;
COUNT retval, keylen,keytyp,keydup,nomemb;
UCOUNT xtdsiz = 1024;
TEXT filnam[15] = "sample.dat";
if (retval = InitCtree(6,7,4))
printf("\nCould not initialize. Error %d.", retval);
else {
if (CreateIndexFile(keyno, filnam, keylen, keytyp,
keydup, nomemb, 8192, (ctSHARED | ctVIRTUAL)))
printf("\nError %d creating file %.14s",uerr_cod,
filnam);
else {
if (CreateIndexMember(keyno, keylen2, keytyp2,
keydup2, membno);
printf("Error %d adding member %d.", uerr_cod,
membno);
if (CloseCtFile(keyno, 0))
printf("\nCould not close file.");
if (OpenCtFile(keyno, filnam,
(ctSHARED | ctVIRTUAL | ctFIXED)))
printf("\nCould not open file.");
else if (CloseCtFile(keyno, 0))
printf("\nCould not close file.");
}
if (CloseISAM())
printf("\nCould not close ISAM.");
}
Limitations
See the Limitations discussion under CreateIndexFile().
See also
InitCTree, SetAlternateSequence, InitCTree, CreateIndexFile, OpenCtFile and FairCom DB Keys for a discussion on how automatic support of duplicate keys is handled.