Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbAttachTableXtd

Attaches a FairCom DB ISAM datno object to a c-treeDB API table handle allowing a DODA and IFIL to be specified.

DECLARATION

CTDBRET ctdbAttachTableXtd(CTHANDLE Handle, NINT datno, NINT nbrfields, pDATOBJ dodaptr, pIFIL ifilptr)

DESCRIPTION

ctdbAttachTableXtd() attaches a FairCom DB ISAM datno object to a c-treeDB API table handle. 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 API 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 API.

Handle is a table handle and 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.

RETURN

Value

Symbolic Constant

Explanation

0

NO_ERROR

No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

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};


CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTREE);

CTHANDLE hTable = ctdbAllocTable(hSession);

CTHANDLE hRecord = ctdbAllocRecord(hTable);

NINT datno, count = 0;


/* logon to c-tree */

ctdbLogon(hSession, SERVER, USER, PASSWD);


/* open the file using c-tree ISAM */

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


/* attach to table */

ctdbAttachTableXtd(hTable, datno, doda, &ifil);


/* read the records */

if (ctdbFirstRecord(hRecord) == CTDBRET_OK)

do

{

count++;

}

while (ctdbNextRecord(hRecord) == CTDBRET_OK);


/* cleanup */

ctdbDetachtable(hTable);

ctdbFreeRecord(hRecord);

ctdbFreeTable(hTable);

ctdbLogout(hSession);

ctdbFreeSession(hSession);

SEE ALSO

ctdbAttachTable(), ctdbDetachTable()

TOCIndex