Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

CTIndex::SetIndexFileName

Sets the index file name of the given index name or number.

Declaration

void CTTable::SetIndexFilename(const CTString& IndexName, const CTString* path, const CTString* filename)

void CTTable::SetIndexFilename(NINT IndexNumber, const CTSTring* path, const CTString* filename)

Description

Sets the index file path and name of the given index name or number. By default, when a table is created, all indexes are created as members of one index file with the table name and path, and with the extension .idx. SetIndexFileName() allows the specification of a file name and path for any one of the table’s indexes. If an index file name is not specified, the index will be created as a member of the previous index file. If no index file name and path is specified, the default is applied. If all indexes of a table specify an index file name and path, each index will be placed in a separate index file.

  • path specifies the directory were the index file is located. If path is NULL the index is located in the same directory of its table.
  • Indexname specifies the name of index file. If name is NULL the index file will use the name of its table.
  • filename is the name to assign to the index file.

Return

void

Example


void CreateTable(CTDatabase& hDatabase, const CTString& tabName, const CTString& idxName)

{

CTTable hTable(hDatabase);


try

{

hTable.AddField("name", CT_FSTRING, 20);

hTable.AddField("surname", CT_FSTRING, 20);

hTable.AddField("code", CT_INT4, 4);

hTable.AddIndex("index1", CTINDEX_FIXED, NO, NO);

hTable.SetIndexFilename("index1", NULL, IdxName);

hTable.AddSegment("index1", "surname", CTSEG_SCHSEG);

hTable.AddSegment("index1", "code", CTSEG_SCHSEG);

hTable.Create(tabName, CTCREATE_NORMAL);

}

catch (CTException &err)

{

printf("Error: %d - %s\n", err.GetErrorMsg(), err.GetErrorCode());

}

}

See Also

CTTable:GetIndexFilename(), CTTable::SetIndexFilename, CTIndex::SetIndexFilename

TOCIndex