Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

CTTable::AttachXtd

Attaches a c-tree Plus ISAM datno object to a c-treeDB table handle allowing a DODA and IFIL to be specified.

Declaration

void CTTable::AttachXtd(NINT datno, NINT nbrfields, pDATOBJ dodaptr,
pIFIL ifilptr);

Description

  • datno is the data file number.
  • nbrfields is the number of fields described by dodaptr. If nbrfields is zero, it is assumed that the DODA is not supplied and a DODA resource will be read from the table itself.
  • dodaptr pointer to DODA entries for each field in table. If dodaptr is NULL, it is assumed that the DODA is not supplied and a DODA resource will be read from the table itself.
  • ifilptr is a pointer to IFIL structure describing indexes of table. If ifilptr is NULL it is assumed that an IFIL is not supplied and an IFIL resource will be read from the table itself.

CTTable::AttachXtd() attaches a c-tree Plus ISAM datno object to a c-treeDB table object. This function is useful if you have opened a data and index file using one of c-tree’s ISAM open functions and need to attach it to a table handle to use some of the advanced c-treeDB features such as alter table or the record handler. This extended version allows the user to specify the DODA and IFIL for the table, enabling tables without DODA and/or IFIL to be attached to c-treeDB.

Return

void

Example


/* DODA */

static DATOBJ doda[] =

{

{"f1", (pTEXT)0, CT_INT4, 4},

{"f2", (pTEXT)4, CT_FSTRING, 10}

};

/* IFIL */

static ISEG iseg = {0, 4, 12};

static IIDX iidx = {4, 0, 0, 0, 0, 1, &iseg, "i311x1", NULL, NULL, NULL};

static IFIL ifil = {"test310", -1, 14, 0, 0, 1, 0, 0, &iidx, "f1", "f2", 0};

CTSession hSession(CTSESSION_CTREE);

CTTable hTable(hSession);

CTRecord hRecord(hTable);

NINT datno, count = 0;

// logon to c-tree

hSession.Logon(SERVER, USER, PASSWD);

// open the file using c-tree ISAM

datno = (NINT)OPNRFILX((COUNT) -1, "test309.dat", (COUNT)0, NULL);)

// attach to table

hTable.AttachXtd(datno, 2, doda, &ifil);

// read the records

if (hRecord.First())

do

{

count++;

}

while (hRecord.Next());

// cleanup

hTable.Detach();

hSession.Logout();

TOCIndex