ctdbAttachTable
Attaches a FairCom DB ISAM datno object to a FairCom DB API table handle.
DECLARATION
CTDBRET ctdbAttachTable(CTHANDLE Handle, NINT datno);
DESCRIPTION
ctdbAttachTable() attaches a FairCom DB ISAM datno object to a FairCom DB 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 FairCom DB API features such as alter table or the record handler. Handle is a table handle and datno is data file number opened with one of the c-tree ISAM open functions.
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
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 */
ctdbAttachTable(hTable, datno);
/* 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
ctdbAttachXtd, ctdbDetach